예제 #1
0
 public void SetViewData(ObjectContent objectContent, string[] properties)
 {
     Dictionary<string, ObjectContent> objectContentList = new Dictionary<string, ObjectContent>();
     objectContentList.Add(objectContent.Obj.Value, objectContent);
     Dictionary<string, ViewBase> generatedManagedObjectList = new Dictionary<string, ViewBase>();
     PropertyFilterSpec resultPropertyFilterSpec;
     Dictionary<string, List<string>> currentAllowedPropertyPath;
     DynamicPropertyFilterSpecGenerator.Generate(objectContent.Obj, properties, out resultPropertyFilterSpec, out currentAllowedPropertyPath);
     ViewBase.SetViewData(this, (string)null, currentAllowedPropertyPath, objectContentList, generatedManagedObjectList);
 }
예제 #2
0
        public List <ViewBase> GetViewsByMorefs(IEnumerable <ManagedObjectReference> moRefs, params string[] properties)
        {
            if (moRefs == null)
            {
                throw new ArgumentNullException("moRefs");
            }
            if (this._vimService == null)
            {
                throw new InvalidOperationException(Resources.VimWebServiceNotInitialized);
            }
            if (this._serviceContent == null)
            {
                throw new InvalidOperationException(Resources.ServiceContentNotInitialized);
            }
            Dictionary <string, PropertyFilterSpec> propertyFilterSpecList = new Dictionary <string, PropertyFilterSpec>();

            foreach (ManagedObjectReference moRef in moRefs)
            {
                if (propertyFilterSpecList.ContainsKey(moRef.Type.ToLower()))
                {
                    PropertyFilterSpec propertyFilterSpec = propertyFilterSpecList[moRef.Type.ToLower()];
                    ObjectSpec[]       array = new List <ObjectSpec>((IEnumerable <ObjectSpec>)propertyFilterSpec.ObjectSet)
                    {
                        new ObjectSpec()
                        {
                            Obj = moRef
                        }
                    }.ToArray();
                    propertyFilterSpec.ObjectSet = array;
                }
                else
                {
                    PropertyFilterSpec resultPropertyFilterSpec;
                    Dictionary <string, List <string> > currentAllowedPropertyPath;
                    DynamicPropertyFilterSpecGenerator.Generate(moRef, properties, out resultPropertyFilterSpec, out currentAllowedPropertyPath);
                    propertyFilterSpecList.Add(moRef.Type.ToLower(), resultPropertyFilterSpec);
                }
            }
            PropertyFilterSpec[] propertyFilterSpecArray = new PropertyFilterSpec[propertyFilterSpecList.Values.Count];
            propertyFilterSpecList.Values.CopyTo(propertyFilterSpecArray, 0);
            ObjectContent[] objectContent = new PropertyCollector((VimClient)this, this._serviceContent.PropertyCollector).RetrieveProperties(propertyFilterSpecArray);
            return(this.GetViewsByMorefs(moRefs, objectContent, propertyFilterSpecList));
        }
예제 #3
0
 public void UpdateViewData(params string[] properties)
 {
     PropertyCollector propertyCollector = new PropertyCollector(this._client, this._client.ServiceContent.PropertyCollector);
     PropertyFilterSpec resultPropertyFilterSpec;
     Dictionary<string, List<string>> currentAllowedPropertyPath;
     DynamicPropertyFilterSpecGenerator.Generate(this.MoRef, VimClient.MakePropertiesCamelCase(properties), out resultPropertyFilterSpec, out currentAllowedPropertyPath);
     PropertyFilterSpec[] specSet = new PropertyFilterSpec[1]
     {
 resultPropertyFilterSpec
     };
     ObjectContent[] objectContentArray = propertyCollector.RetrieveProperties(specSet);
     Dictionary<string, ObjectContent> objectContentList = new Dictionary<string, ObjectContent>();
     foreach (ObjectContent objectContent in objectContentArray)
         objectContentList.Add(objectContent.Obj.Value, objectContent);
     Dictionary<string, ViewBase> generatedManagedObjectList = new Dictionary<string, ViewBase>();
     if (properties != null)
     {
         List<string> stringList = new List<string>((IEnumerable<string>)properties);
     }
     ViewBase.SetViewData(this, (string)null, currentAllowedPropertyPath, objectContentList, generatedManagedObjectList);
 }