Exemplo n.º 1
0
        /// <summary>
        /// Create instances of SampleClassificationObjectType, adding them to the private objects collection.
        /// </summary>
        /// <param name="entry"></param>
        private void ProcessResourceEntry(SampleResourceEntry entry)
        {
            // Create Property provider by matching property adapters with data sources
            // PropertyProvider is called by ResourceStaticAnalysis when code attempts to retrieve a property that has not yet been created
            var pp = new PropertyProvider();

            // Add a pair: property adapter and an object that serves as source
            foreach (var adapter in resourceFilePropertyAdapters)
            {
                pp.AddPropertyAdapterDataSourcePair(adapter, entry);
            }
            // Initialize an instance of SampleClassificationObjectType using the PropertyProvider built above
            var obj = new SampleClassificationObjectType(pp);

            foreach (var adapter in selfPropertyAdapters)
            {
                // Now, add one more poperty adapter that uses the SampleClassificationObjectType object itself as data source
                // this one builds properties from existing properties.
                pp.AddPropertyAdapterDataSourcePair(adapter, obj);
            }

            // This reduces amount of memory used by object by compacting internal representation.
            pp.Compact();
            // Add to the list of all objects being constructed by this adapter.
            objects.Add(obj);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is used to parse a list of tuple to a list of <see cref="SampleClassificationObjectType"/>.
        /// </summary>
        /// <param name="sampleResources">A list of tuple to be parsed.</param>
        /// <returns>A list of <see cref="SampleClassificationObjectType"/>.</returns>
        private static List <SampleClassificationObjectType> ParseResStrInfoToCOs(List <Tuple <string, string, string> > resourceTuples)
        {
            SampleResourceCollection sampleResourceCollection = new SampleResourceCollection(resourceTuples);

            List <SampleClassificationObjectType> sampleClassificationObjects = new List <SampleClassificationObjectType>();

            SamplePropertyAdapter samplePropertyAdapter = new SamplePropertyAdapter();

            sampleResourceCollection.Entries.ForEach(sampleResource =>
            {
                PropertyProvider propertyProvider = new PropertyProvider();
                propertyProvider.AddPropertyAdapterDataSourcePair(samplePropertyAdapter, sampleResource);
                SampleClassificationObjectType sampleClassificationObject = new SampleClassificationObjectType(propertyProvider);
                sampleClassificationObjects.Add(sampleClassificationObject);
            });

            return(sampleClassificationObjects);
        }