本文整理汇总了C#中IXenObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IXenObject.GetType方法的具体用法?C# IXenObject.GetType怎么用?C# IXenObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXenObject
的用法示例。
在下文中一共展示了IXenObject.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveCustomFieldsAction
public SaveCustomFieldsAction(IXenObject xenObject, List<CustomField> customFields, bool suppressHistory)
: base(xenObject.Connection, Messages.ACTION_SAVE_CUSTOM_FIELDS, string.Format(Messages.ACTION_SAVING_CUSTOM_FIELDS_FOR, xenObject), suppressHistory)
{
this.xenObject = xenObject;
this.customFields = customFields;
string type = xenObject.GetType().Name.ToLowerInvariant();
}
示例2: PerfmonDefinitionAction
public PerfmonDefinitionAction(IXenObject xo, List<PerfmonDefinition> perfmonDefinitions)
: base(xo.Connection, Messages.ACTION_SAVE_ALERTS, string.Format(Messages.ACTION_SAVING_ALERTS_FOR, xo))
{
this.xo = xo;
this.perfmonDefinitions = perfmonDefinitions;
string type = xo.GetType().Name.ToLowerInvariant();
ApiMethodsToRoleCheck.Add(type + ".remove_from_other_config", PerfmonDefinition.PERFMON_KEY_NAME);
if (perfmonDefinitions != null && perfmonDefinitions.Count != 0)
ApiMethodsToRoleCheck.Add(type + ".add_to_other_config", PerfmonDefinition.PERFMON_KEY_NAME);
}
示例3: AddTagAction
public static DelegatedAsyncAction AddTagAction(IXenObject o, string tag)
{
return new DelegatedAsyncAction(o.Connection,
String.Format(Messages.ADD_TAG, tag),
String.Format(Messages.ADDING_TAG, tag),
String.Format(Messages.ADDED_TAG, tag),
delegate(Session session)
{
Tags.AddTag(session, o, tag);
},
o.GetType().Name.ToLowerInvariant() + ".add_tags"
);
}
示例4: GeneralEditPageAction
public GeneralEditPageAction(IXenObject xenObjectOrig, IXenObject xenObjectCopy, string newFolder, List<string> newTags, bool suppressHistory)
: base(xenObjectCopy.Connection, Messages.ACTION_SAVE_FOLDER_TAGS, string.Format(Messages.ACTION_SAVING_FOLDER_TAGS_FOR, xenObjectCopy), suppressHistory)
{
this.xenObjectOrig = xenObjectOrig;
this.xenObjectCopy = xenObjectCopy;
this.newFolder = newFolder;
this.oldTags = new List<string>(Tags.GetTags(xenObjectCopy));
this.newTags = newTags;
oldTags.Sort();
newTags.Sort();
string type = xenObjectCopy.GetType().Name.ToLowerInvariant();
if (newFolder != xenObjectCopy.Path)
{
ApiMethodsToRoleCheck.Add(type + ".remove_from_other_config", Folders.FOLDER);
if (!String.IsNullOrEmpty(newFolder))
ApiMethodsToRoleCheck.Add(type + ".add_to_other_config", Folders.FOLDER);
// TODO: Full RBAC for folders
}
foreach (string tag in oldTags)
{
if (newTags.BinarySearch(tag) < 0)
{
ApiMethodsToRoleCheck.Add(type + ".remove_tags");
break;
}
}
foreach (string tag in newTags)
{
if (oldTags.BinarySearch(tag) < 0)
{
ApiMethodsToRoleCheck.Add(type + ".add_tags");
break;
}
}
}
示例5: TypeOf
private static string TypeOf(IXenObject o)
{
if (o is Folder)
return "10";
if (o is Pool)
return "20";
if (o is Host)
return "30";
VM vm = o as VM;
if (vm != null && vm.is_a_real_vm)
return "40";
return o.GetType().ToString();
}
示例6: PropertiesDialog
public PropertiesDialog(IXenObject xenObject)
: base(xenObject.Connection)
{
// xenObject must not be null. If this occurs, we shouldn't have offered Properties in the UI.
Debug.Assert(xenObject != null, "XenObject is null");
InitializeComponent();
this.xenObject = xenObject;
xenObjectBefore = xenObject.Clone();
xenObjectCopy = xenObject.Clone();
Name = String.Format("Edit{0}GeneralSettingsDialog", xenObject.GetType().Name);
Text = String.Format(Messages.PROPERTIES_DIALOG_TITLE, Helpers.GetName(xenObject));
if (!Application.RenderWithVisualStyles)
ContentPanel.BackColor = SystemColors.Control;
Build();
}
示例7: MoveToFolderAction
public MoveToFolderAction(IXenObject obj, Folder folder)
: base(obj.Connection, string.Format(Messages.MOVE_OBJECT_TO_FOLDER, Helpers.GetName(obj), folder.Name))
{
this.objs.Add(obj);
this.folder = folder;
if (obj.GetType() != typeof(Folder))
{
ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".remove_from_other_config",
Folders.FOLDER);
ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".add_to_other_config",
Folders.FOLDER);
}
AppliesTo.Add(obj.opaque_ref);
AppliesTo.Add(folder.opaque_ref);
}
示例8: DeleteFolderAction
public DeleteFolderAction(IXenObject obj)
: base(obj.Connection, Messages.DELETING_FOLDER)
{
objs.Add(obj);
if (obj.GetType() != typeof(Folder))
{
ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".remove_from_other_config",
Folders.FOLDER);
ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".add_to_other_config",
Folders.FOLDER);
}
AppliesTo.Add(obj.opaque_ref);
}
示例9: SaveChangesAction
protected SaveChangesAction(IXenObject obj, bool suppressHistory)
: base(obj.Connection, Messages.ACTION_SAVE_CHANGES_TITLE, Messages.ACTION_SAVE_CHANGES_IN_PROGRESS, suppressHistory)
{
// This is lovely. We need to lock the server object (not the copy we have taken) before calling save changes.
// We don't know the type so we use the MethodInfo object and MakeGenericMethod to do a resolve against the type
// we have extracted from GetType(). The Resolve() call itself needs a XenRef which we make by calling the XenRef constructor that takes the
// opaque ref as an argument and using the MakeGenericType call to give it the same type as the object...
// ... _then_ we lock it.
SetObject(obj);
_xenObject = obj;
if (obj.opaque_ref != null) // creating a new object comes through here, but with obj.opaque_ref == null
{
System.Reflection.MethodInfo mi = typeof(IXenConnection).GetMethod("Resolve", BindingFlags.Public | BindingFlags.Instance);
Type type = obj.GetType();
object[] xenRefParam = new object[] {
typeof(XenRef<>).MakeGenericType(type).GetConstructor(new Type[] {typeof(string)}).Invoke(new Object[] {obj.opaque_ref})
};
_serverXenObject = (IXenObject)mi.MakeGenericMethod(type).Invoke(obj.Connection, xenRefParam);
if (_serverXenObject != null)
{
// CA-35210: Removed this exception pending locking overhaul post MR in CA-38966
//if (_serverXenObject.Locked)
// lockViolation = true;
_serverXenObject.Locked = true;
}
}
}
示例10: SetObject
public void SetObject(IXenObject XenObject)
{
// Annoyingly all of our classes start with an uppercase character, whereas the servers only uppercase abbreviations
List<string> abbreviations = new List<string>(new string[]{"SR", "VDI", "VBD", "VM", "PIF", "VIF", "PBD"});
SelectedObjectType = XenObject.GetType().Name;
if (abbreviations.Find(delegate(string s) { return SelectedObjectType.StartsWith(s); }) == null)
{
string firstLetter = SelectedObjectType.Substring(0, 1);
SelectedObjectType = firstLetter.ToLowerInvariant() + SelectedObjectType.Substring(1, SelectedObjectType.Length - 1);
}
SelectedObjectRef = XenObject.opaque_ref;
}
示例11: RetrieveParams
// Returns a set of params which relate to the object you have selected in the treeview
private List<string> RetrieveParams(IXenObject obj)
{
IXenConnection connection = obj.Connection;
Host master = connection != null ? Helpers.GetMaster(connection) : null; // get master asserts connection is not null
string masterAddress = EmptyParameter;
if (master != null)
{
masterAddress = Helpers.GetUrl(master.Connection);
WriteTrustedCertificates(master.Connection);
}
string sessionRef = connection.Session != null ? connection.Session.uuid : EmptyParameter;
string objCls = obj != null ? obj.GetType().Name : EmptyParameter;
string objUuid = obj != null && connection.Session != null ? Helpers.GetUuid(obj) : EmptyParameter;
return new List<string>(new string[] { masterAddress, sessionRef, objCls, objUuid });
}
示例12: RemoveTagAction
public static DelegatedAsyncAction RemoveTagAction(IXenObject o, string tag)
{
return new DelegatedAsyncAction(o.Connection,
String.Format(Messages.DELETE_TAG, tag),
String.Format(Messages.DELETING_TAG, tag),
String.Format(Messages.DELETED_TAG, tag),
delegate(Session session)
{
Tags.RemoveTag(session, o, tag);
},
o.GetType().Name.ToLowerInvariant() + ".remove_tags"
);
}
示例13: SetRandomStuffToFields
/// <summary>
/// Sets the random stuff to the string, int, long, double fields of the specified object.
/// </summary>
private void SetRandomStuffToFields(IXenObject xenObject)
{
foreach (FieldInfo fi in xenObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if (!fi.IsInitOnly && !fi.IsLiteral) //check field isn't const or readonly
{
if (fi.FieldType == typeof(string))
{
fi.SetValue(xenObject, Guid.NewGuid().ToString());
}
else if (fi.FieldType == typeof(int) || fi.FieldType == typeof(long) || fi.FieldType == typeof(double))
{
fi.SetValue(xenObject, _random.Next());
}
}
}
}
示例14: IEquatableEquals
/// <summary>
/// Iterate through all implemented IEquatable<T> interfaces and call Equals on each, if any of them
/// return false, then this method returns false, otherwise it returns true.
///
/// Both o and oo should be of the same type.
/// </summary>
private bool IEquatableEquals(IXenObject o, IXenObject oo)
{
Assert.AreEqual(o.GetType(), oo.GetType());
foreach (Type iface in o.GetType().GetInterfaces())
{
if (iface.Name.StartsWith("IEquatable"))
{
MethodInfo mi = iface.GetMethod("Equals");
if (!(bool)mi.Invoke(o, new object[] { oo }))
{
return false;
}
}
}
return true;
}
示例15: FolderAction
// Constructor used for Move and Delete
public FolderAction(IXenObject obj, Folder folder, Kind kind)
: base(obj.Connection, GetTitle(obj, folder, kind))
{
System.Diagnostics.Trace.Assert(kind == Kind.Move || kind == Kind.Delete);
this.obj = obj;
this.folder = folder;
this.kind = kind;
if ( obj.GetType() != typeof(Folder) )
{
ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".remove_from_other_config",
Folders.FOLDER);
ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".add_to_other_config",
Folders.FOLDER);
}
ApiMethodsToRoleCheck.Add("pool.remove_from_other_config", Folders.EMPTY_FOLDERS);
ApiMethodsToRoleCheck.Add("pool.add_to_other_config", Folders.EMPTY_FOLDERS);
AppliesTo.Add(obj.opaque_ref);
if (folder != null)
AppliesTo.Add(folder.opaque_ref);
}