本文整理汇总了C#中System.Diagnostics.EventLogPermission类的典型用法代码示例。如果您正苦于以下问题:C# EventLogPermission类的具体用法?C# EventLogPermission怎么用?C# EventLogPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventLogPermission类属于System.Diagnostics命名空间,在下文中一共展示了EventLogPermission类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetEventLogPermission
public static EventLogPermission GetEventLogPermission()
{
EventLogPermission permission = new EventLogPermission();
EventLogPermissionEntry entry = new EventLogPermissionEntry(EventLogPermissionAccess.Administer, ".");
permission.PermissionEntries.Add(entry);
return permission;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:EventLogPermissionHolder.cs
示例2: EventLogPermissionEntryCollection
internal EventLogPermissionEntryCollection(EventLogPermission owner, ResourcePermissionBaseEntry[] entries)
{
this.owner = owner;
for (int i = 0; i < entries.Length; i++)
{
base.InnerList.Add(new EventLogPermissionEntry(entries[i]));
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:EventLogPermissionEntryCollection.cs
示例3: EventLogPermissionEntryCollection
internal EventLogPermissionEntryCollection (EventLogPermission owner)
{
this.owner = owner;
ResourcePermissionBaseEntry[] entries = owner.GetEntries ();
if (entries.Length > 0) {
foreach (ResourcePermissionBaseEntry entry in entries) {
EventLogPermissionAccess elpa = (EventLogPermissionAccess) entry.PermissionAccess;
EventLogPermissionEntry elpe = new EventLogPermissionEntry (elpa, entry.PermissionAccessPath [0]);
// we don't want to add them (again) to the base class
InnerList.Add (elpe);
}
}
}
开发者ID:Xipas,项目名称:Symplified.Auth,代码行数:13,代码来源:EventLogPermissionEntryCollection.cs
示例4: PermissionState_Unrestricted
public void PermissionState_Unrestricted ()
{
PermissionState ps = PermissionState.Unrestricted;
EventLogPermission elp = new EventLogPermission (ps);
Assert.AreEqual (0, elp.PermissionEntries.Count, "PermissionEntries");
Assert.IsTrue (elp.IsUnrestricted (), "IsUnrestricted");
SecurityElement se = elp.ToXml ();
// only class and version are present
Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted");
Assert.IsNull (se.Children, "Xml-Children");
EventLogPermission copy = (EventLogPermission)elp.Copy ();
Assert.IsFalse (Object.ReferenceEquals (elp, copy), "ReferenceEquals");
Assert.AreEqual (elp.PermissionEntries.Count, copy.PermissionEntries.Count, "copy-PermissionEntries");
Assert.AreEqual (elp.IsUnrestricted (), copy.IsUnrestricted (), "copy-IsUnrestricted ()");
}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:EventLogPermissionTest.cs
示例5: Log
/// <summary>
/// Logs message.
/// </summary>
/// <param name="message">A message to log.</param>
/// <param name="source">Name of the event source to log to.</param>
/// <param name="entryType">The type of entry to log.</param>
public static void Log(String message, String source, EventLogEntryType entryType)
{
// Use one source
// source = ConfigurationManager.AppSettings["EventLogSource"];
EventLogPermission eventLogPermission = new EventLogPermission(EventLogPermissionAccess.Administer, ".");
eventLogPermission.PermitOnly();
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, "Application");
}
EventLog.WriteEntry(source, message, entryType);
Writer.WriteLine(string.Format("LOGGED: {0}", message));
}
开发者ID:stevedubyo,项目名称:dublogging,代码行数:23,代码来源:Logger.cs
示例6: FromXml_WrongVersion
public void FromXml_WrongVersion ()
{
EventLogPermission elp = new EventLogPermission (PermissionState.None);
SecurityElement se = elp.ToXml ();
se.Attributes.Remove ("version");
se.Attributes.Add ("version", "2");
elp.FromXml (se);
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:EventLogPermissionTest.cs
示例7: FromXml_WrongClass
public void FromXml_WrongClass ()
{
EventLogPermission elp = new EventLogPermission (PermissionState.None);
SecurityElement se = elp.ToXml ();
SecurityElement w = new SecurityElement (se.Tag);
w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
w.AddAttribute ("version", se.Attribute ("version"));
elp.FromXml (w);
// doesn't care of the class name at that stage
// anyway the class has already be created so...
}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:EventLogPermissionTest.cs
示例8: FromXml_Null
public void FromXml_Null ()
{
EventLogPermission elp = new EventLogPermission (PermissionState.None);
elp.FromXml (null);
}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:EventLogPermissionTest.cs
示例9: Union_Unrestricted
public void Union_Unrestricted ()
{
// Union with unrestricted is unrestricted
EventLogPermission elp1 = new EventLogPermission (PermissionState.Unrestricted);
foreach (EventLogPermissionAccess elpa in AllAccess) {
EventLogPermission elp2 = new EventLogPermission (PermissionState.None);
elp2.PermissionEntries.Add (new EventLogPermissionEntry (elpa, elpa.ToString ()));
EventLogPermission union = (EventLogPermission)elp1.Union (elp2);
Assert.IsTrue (union.IsUnrestricted (), "target.IsUnrestricted " + elpa.ToString ());
Assert.AreEqual (0, union.PermissionEntries.Count, "target.Count " + elpa.ToString ());
union = (EventLogPermission)elp2.Union (elp1);
Assert.IsTrue (union.IsUnrestricted (), "source.IsUnrestricted " + elpa.ToString ());
Assert.AreEqual (0, union.PermissionEntries.Count, "source.Count " + elpa.ToString ());
}
}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:EventLogPermissionTest.cs
示例10: Union_Null
public void Union_Null ()
{
EventLogPermission elp = new EventLogPermission (PermissionState.None);
elp.PermissionEntries.Add (new EventLogPermissionEntry (EventLogPermissionAccess.None, "localhost"));
// Union with null is a simple copy
EventLogPermission union = (EventLogPermission)elp.Union (null);
Assert.IsNotNull (elp.PermissionEntries.Count, "Count");
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:EventLogPermissionTest.cs
示例11: EventLogPermissionAccesss_Bad
public void EventLogPermissionAccesss_Bad ()
{
EventLogPermissionAccess elpa = (EventLogPermissionAccess)Int32.MinValue;
EventLogPermission elp = new EventLogPermission (elpa, "localhost");
Assert.AreEqual (1, elp.PermissionEntries.Count, "Count");
Assert.AreEqual ((EventLogPermissionAccess)Int32.MinValue, elp.PermissionEntries [0].PermissionAccess, "PermissionAccess");
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:EventLogPermissionTest.cs
示例12: Constructor_MachineName_Null
public void Constructor_MachineName_Null ()
{
EventLogPermission elp = new EventLogPermission (EventLogPermissionAccess.None, null);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:EventLogPermissionTest.cs
示例13: Constructor_PermissionEntries_Null
public void Constructor_PermissionEntries_Null ()
{
EventLogPermission elp = new EventLogPermission (null);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:EventLogPermissionTest.cs
示例14: EndInit
/// <devdoc>
/// </devdoc>
public void EndInit() {
string currentMachineName = this.machineName;
EventLogPermission permission = new EventLogPermission(EventLogPermissionAccess.Write, currentMachineName);
permission.Demand();
boolFlags[Flag_initializing] = false;
if (boolFlags[Flag_monitoring])
StartListening(currentMachineName, GetLogName(currentMachineName));
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:EventLogInternal.cs
示例15: Close
private void Close(string currentMachineName) {
EventLogPermission permission = new EventLogPermission(EventLogPermissionAccess.Write, currentMachineName);
permission.Demand();
Debug.WriteLineIf(CompModSwitches.EventLog.TraceVerbose, "EventLog::Close");
//Trace("Close", "Closing the event log");
if (readHandle != null) {
try {
readHandle.Close();
}
catch (IOException) {
throw SharedUtils.CreateSafeWin32Exception();
}
readHandle = null;
//Trace("Close", "Closed read handle");
Debug.WriteLineIf(CompModSwitches.EventLog.TraceVerbose, "EventLog::Close: closed read handle");
}
if (writeHandle != null) {
try {
writeHandle.Close();
}
catch (IOException) {
throw SharedUtils.CreateSafeWin32Exception();
}
writeHandle = null;
//Trace("Close", "Closed write handle");
Debug.WriteLineIf(CompModSwitches.EventLog.TraceVerbose, "EventLog::Close: closed write handle");
}
if (boolFlags[Flag_monitoring])
StopRaisingEvents(/*currentMachineName,*/ GetLogName(currentMachineName));
if (messageLibraries != null) {
foreach (SafeLibraryHandle handle in messageLibraries.Values)
handle.Close();
messageLibraries = null;
}
boolFlags[Flag_sourceVerified] = false;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:40,代码来源:EventLogInternal.cs
示例16: IsSubset_Unrestricted
public void IsSubset_Unrestricted ()
{
// IsSubset with unrestricted
// a. source (this) is unrestricted -> target is never a subset
// b. destination (target) is unrestricted -> source is always a subset
EventLogPermission elp1 = new EventLogPermission (PermissionState.Unrestricted);
foreach (EventLogPermissionAccess elpa in AllAccess) {
EventLogPermission elp2 = new EventLogPermission (PermissionState.None);
elp2.PermissionEntries.Add (new EventLogPermissionEntry (elpa, elpa.ToString ()));
Assert.IsFalse (elp1.IsSubsetOf (elp2), "target " + elpa.ToString ());
Assert.IsTrue (elp2.IsSubsetOf (elp1), "source " + elpa.ToString ());
}
Assert.IsTrue (elp1.IsSubsetOf (elp1), "Unrestricted.IsSubsetOf(Unrestricted)");
}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:EventLogPermissionTest.cs
示例17: IsSubsetOf_BadPermission
// "special" behavior inherited from ResourceBasePermission
// [ExpectedException (typeof (ArgumentException))]
public void IsSubsetOf_BadPermission ()
{
EventLogPermission elp1 = new EventLogPermission (PermissionState.Unrestricted);
Assert.IsFalse (elp1.IsSubsetOf (new SecurityPermission (SecurityPermissionFlag.Assertion)));
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:EventLogPermissionTest.cs
示例18: PermissionEntries
public void PermissionEntries ()
{
EventLogPermissionAccess elpa = EventLogPermissionAccess.None;
EventLogPermission elp = new EventLogPermission (elpa, "localhost");
EventLogPermissionEntryCollection elpec = elp.PermissionEntries;
Assert.AreEqual (1, elpec.Count, "Count==1");
EventLogPermissionEntry elpe = new EventLogPermissionEntry (EventLogPermissionAccess.Browse, "*");
elp.PermissionEntries.Add (elpe);
Assert.AreEqual (2, elpec.Count, "Count==2");
// remove (same instance)
elp.PermissionEntries.Remove (elpe);
Assert.AreEqual (1, elpec.Count, "Count==1 (b)");
// remove different instance (doesn't work)
elpe = new EventLogPermissionEntry (EventLogPermissionAccess.None, "localhost");
Assert.AreEqual (1, elpec.Count, "Count==1");
}
开发者ID:nlhepler,项目名称:mono,代码行数:19,代码来源:EventLogPermissionTest.cs
示例19: Union_Self
public void Union_Self ()
{
foreach (EventLogPermissionAccess elpa in AllAccess)
{
EventLogPermission elp = new EventLogPermission (PermissionState.None);
elp.PermissionEntries.Add (new EventLogPermissionEntry (elpa, elpa.ToString ()));
EventLogPermission union = (EventLogPermission)elp.Union (elp);
Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted " + elpa.ToString ());
Assert.AreEqual (1, union.PermissionEntries.Count, "Count " + elpa.ToString ());
}
}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:EventLogPermissionTest.cs
示例20: Copy
public void Copy ()
{
foreach (EventLogPermissionAccess elpa in AllAccess) {
EventLogPermission elp = new EventLogPermission (PermissionState.None);
EventLogPermissionEntry elpe = new EventLogPermissionEntry (elpa, elpa.ToString ());
elp.PermissionEntries.Add (elpe);
EventLogPermission copy = (EventLogPermission)elp.Copy ();
Assert.AreEqual (1, copy.PermissionEntries.Count, "Count==1");
Assert.AreEqual (elpa, elp.PermissionEntries [0].PermissionAccess, elpa.ToString ());
}
}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:EventLogPermissionTest.cs
注:本文中的System.Diagnostics.EventLogPermission类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论