public List <EntityViewBase> FindEntityViews(System.Type viewType, ManagedObjectReference beginEntity, NameValueCollection filter, string[] properties) { if (viewType == (System.Type)null) { throw new ArgumentNullException("viewType"); } if (this._vimService == null) { throw new InvalidOperationException(Resources.VimWebServiceNotInitialized); } if (this._serviceContent == null) { throw new InvalidOperationException(Resources.ServiceContentNotInitialized); } if (!viewType.IsSubclassOf(typeof(EntityViewBase))) { throw new InvalidOperationException(Resources.InvalidViewTypeParam); } IList <ViewBase> viewBaseList = (IList <ViewBase>)null; ManagedObjectReference beginEntity1 = beginEntity ?? this._serviceContent.RootFolder; string[] strArray = (string[])null; if (filter != null && filter.Count > 0) { string[] propertyList = new string[filter.Count]; filter.AllKeys.CopyTo((Array)propertyList, 0); strArray = VimClient.ValidatePropertyPathList(viewType, propertyList); } ObjectContent[] objectContentArray = new PropertyCollector((VimClient)this, this._serviceContent.PropertyCollector).RetrieveProperties(new PropertyFilterSpec[1] { EntityViewBase.GetSearchFilterSpec((VimClient)this, beginEntity1, new PropertySpec() { All = new bool?(false), Type = viewType.Name, PathSet = strArray }) }); List <ManagedObjectReference> managedObjectReferenceList = new List <ManagedObjectReference>(); if (objectContentArray != null) { foreach (ObjectContent objectContent in objectContentArray) { if (beginEntity == null || !objectContent.Obj.Value.Equals(beginEntity.Value) || !objectContent.Obj.Type.Equals(beginEntity.Type)) { if (filter != null && filter.Count > 0) { DynamicProperty[] propSet = objectContent.PropSet; if (propSet != null) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); foreach (DynamicProperty dynamicProperty in propSet) { dictionary.Add(dynamicProperty.Name, dynamicProperty.Val); } if (dictionary.Count > 0 && VimClient.MatchProperyList(filter, viewType, (IDictionary <string, object>)dictionary)) { managedObjectReferenceList.Add(objectContent.Obj); } } } else { managedObjectReferenceList.Add(objectContent.Obj); } } } } if (managedObjectReferenceList.Count > 0) { viewBaseList = (IList <ViewBase>) this.GetViewsByMorefs((IEnumerable <ManagedObjectReference>)managedObjectReferenceList, properties); } List <EntityViewBase> entityViewBaseList = (List <EntityViewBase>)null; if (viewBaseList != null) { entityViewBaseList = new List <EntityViewBase>(); foreach (ViewBase viewBase in (IEnumerable <ViewBase>)viewBaseList) { EntityViewBase entityViewBase = viewBase as EntityViewBase; entityViewBaseList.Add(entityViewBase); } } return(entityViewBaseList); }
public static PropertyFilterSpec GetSearchFilterSpec(ManagedObjectReference beginEntity, PropertySpec propSpec) { return(EntityViewBase.GetSearchFilterSpec(null, beginEntity, propSpec)); }