Esempio n. 1
0
        /// <summary>
        /// Prepares the project for being built.
        /// </summary>
        /// <param name="solutionConfiguration">The solution configuration that is built.</param>
        /// <remarks>
        /// The default implementation will ensure that none of the output files
        /// are marked read-only.
        /// </remarks>
        protected virtual void Prepare(Configuration solutionConfiguration)
        {
            // determine the output files of the project
            Hashtable outputFiles = CollectionsUtil.CreateCaseInsensitiveHashtable();

            GetOutputFiles(solutionConfiguration, outputFiles);

            // use the <attrib> task to ensure none of the output files are
            // marked read-only
            AttribTask attribTask = new AttribTask();

            // parent is solution task
            attribTask.Parent = SolutionTask;

            // inherit project from solution task
            attribTask.Project = SolutionTask.Project;

            // inherit namespace manager from solution task
            attribTask.NamespaceManager = SolutionTask.NamespaceManager;

            // inherit verbose setting from solution task
            attribTask.Verbose = SolutionTask.Verbose;

            // only output warning messages or higher, unless
            // we're running in verbose mode
            if (!attribTask.Verbose)
            {
                attribTask.Threshold = Level.Warning;
            }

            // make sure framework specific information is set
            attribTask.InitializeTaskConfiguration();

            // set parent of child elements
            attribTask.AttribFileSet.Parent = attribTask;

            // inherit project for child elements from containing task
            attribTask.AttribFileSet.Project = attribTask.Project;

            // inherit namespace manager from containing task
            attribTask.AttribFileSet.NamespaceManager = attribTask.NamespaceManager;

            // we want to reset the read-only attribute of all output files
            attribTask.ReadOnlyAttrib = false;

            // obtain project configuration (corresponding with solution configuration)
            ConfigurationBase config = BuildConfigurations[solutionConfiguration];

            // add all output files to the <attrib> fileset
            foreach (DictionaryEntry de in outputFiles)
            {
                attribTask.AttribFileSet.Includes.Add(FileUtils.CombinePaths(
                                                          config.OutputDir.FullName, (string)de.Value));
            }

            // increment indentation level
            attribTask.Project.Indent();

            try {
                // execute task
                attribTask.Execute();
            } finally {
                // restore indentation level
                attribTask.Project.Unindent();
            }
        }
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <StoreContact> GetSelectData(out int count)
        {
            Hashtable            values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable            customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <StoreContact> results      = null;
            StoreContact         item;

            count = 0;

            System.Guid  _rowguid;
            System.Int32 _contactId;
            System.Int32 _contactTypeId;
            System.Int32 _customerId;

            switch (SelectMethod)
            {
            case StoreContactSelectMethod.Get:
                StoreContactKey entityKey = new StoreContactKey();
                entityKey.Load(values);
                item    = StoreContactProvider.Get(entityKey);
                results = new TList <StoreContact>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case StoreContactSelectMethod.GetAll:
                results = StoreContactProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case StoreContactSelectMethod.GetPaged:
                results = StoreContactProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case StoreContactSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = StoreContactProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = StoreContactProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case StoreContactSelectMethod.GetByCustomerIdContactId:
                _customerId = (values["CustomerId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["CustomerId"], typeof(System.Int32)) : (int)0;
                _contactId  = (values["ContactId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ContactId"], typeof(System.Int32)) : (int)0;
                item        = StoreContactProvider.GetByCustomerIdContactId(_customerId, _contactId);
                results     = new TList <StoreContact>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case StoreContactSelectMethod.GetByRowguid:
                _rowguid = (values["Rowguid"] != null) ? (System.Guid)EntityUtil.ChangeType(values["Rowguid"], typeof(System.Guid)) : Guid.Empty;
                item     = StoreContactProvider.GetByRowguid(_rowguid);
                results  = new TList <StoreContact>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case StoreContactSelectMethod.GetByContactId:
                _contactId = (values["ContactId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ContactId"], typeof(System.Int32)) : (int)0;
                results    = StoreContactProvider.GetByContactId(_contactId, this.StartIndex, this.PageSize, out count);
                break;

            case StoreContactSelectMethod.GetByContactTypeId:
                _contactTypeId = (values["ContactTypeId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ContactTypeId"], typeof(System.Int32)) : (int)0;
                results        = StoreContactProvider.GetByContactTypeId(_contactTypeId, this.StartIndex, this.PageSize, out count);
                break;

            // FK
            case StoreContactSelectMethod.GetByCustomerId:
                _customerId = (values["CustomerId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["CustomerId"], typeof(System.Int32)) : (int)0;
                results     = StoreContactProvider.GetByCustomerId(_customerId, this.StartIndex, this.PageSize, out count);
                break;

            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
 /// <summary>
 /// Creates a new instance, the logger cache being <paramref name="caseSensitiveLoggerCache"/>.
 /// </summary>
 /// <param name="caseSensitiveLoggerCache"></param>
 protected AbstractCachingLoggerFactoryAdapter(bool caseSensitiveLoggerCache)
 {
     _cachedLoggers = (caseSensitiveLoggerCache)
                          ? new Hashtable()
                          : CollectionsUtil.CreateCaseInsensitiveHashtable();
 }
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <Product> GetSelectData(out int count)
        {
            Hashtable       values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable       customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <Product> results      = null;
            Product         item;

            count = 0;

            System.String _name;
            System.String _productNumber;
            System.Guid   _rowguid;
            System.Int32  _productId;
            System.Int32? _productModelId_nullable;
            System.Int32? _productSubcategoryId_nullable;
            System.String _sizeUnitMeasureCode_nullable;
            System.String _weightUnitMeasureCode_nullable;
            System.Int32  _documentId;
            System.Int16  _locationId;
            System.Int32  _productPhotoId;
            System.Int32  _vendorId;
            System.Int32  _specialOfferId;

            switch (SelectMethod)
            {
            case ProductSelectMethod.Get:
                ProductKey entityKey = new ProductKey();
                entityKey.Load(values);
                item    = ProductProvider.Get(entityKey);
                results = new TList <Product>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case ProductSelectMethod.GetAll:
                results = ProductProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case ProductSelectMethod.GetPaged:
                results = ProductProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case ProductSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = ProductProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = ProductProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case ProductSelectMethod.GetByProductId:
                _productId = (values["ProductId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ProductId"], typeof(System.Int32)) : (int)0;
                item       = ProductProvider.GetByProductId(_productId);
                results    = new TList <Product>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case ProductSelectMethod.GetByName:
                _name   = (values["Name"] != null) ? (System.String)EntityUtil.ChangeType(values["Name"], typeof(System.String)) : string.Empty;
                item    = ProductProvider.GetByName(_name);
                results = new TList <Product>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case ProductSelectMethod.GetByProductNumber:
                _productNumber = (values["ProductNumber"] != null) ? (System.String)EntityUtil.ChangeType(values["ProductNumber"], typeof(System.String)) : string.Empty;
                item           = ProductProvider.GetByProductNumber(_productNumber);
                results        = new TList <Product>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case ProductSelectMethod.GetByRowguid:
                _rowguid = (values["Rowguid"] != null) ? (System.Guid)EntityUtil.ChangeType(values["Rowguid"], typeof(System.Guid)) : Guid.Empty;
                item     = ProductProvider.GetByRowguid(_rowguid);
                results  = new TList <Product>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // FK
            case ProductSelectMethod.GetByProductModelId:
                _productModelId_nullable = (System.Int32?)EntityUtil.ChangeType(values["ProductModelId"], typeof(System.Int32?));
                results = ProductProvider.GetByProductModelId(_productModelId_nullable, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetByProductSubcategoryId:
                _productSubcategoryId_nullable = (System.Int32?)EntityUtil.ChangeType(values["ProductSubcategoryId"], typeof(System.Int32?));
                results = ProductProvider.GetByProductSubcategoryId(_productSubcategoryId_nullable, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetBySizeUnitMeasureCode:
                _sizeUnitMeasureCode_nullable = (System.String)EntityUtil.ChangeType(values["SizeUnitMeasureCode"], typeof(System.String));
                results = ProductProvider.GetBySizeUnitMeasureCode(_sizeUnitMeasureCode_nullable, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetByWeightUnitMeasureCode:
                _weightUnitMeasureCode_nullable = (System.String)EntityUtil.ChangeType(values["WeightUnitMeasureCode"], typeof(System.String));
                results = ProductProvider.GetByWeightUnitMeasureCode(_weightUnitMeasureCode_nullable, this.StartIndex, this.PageSize, out count);
                break;

            // M:M
            case ProductSelectMethod.GetByDocumentIdFromProductDocument:
                _documentId = (values["DocumentId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["DocumentId"], typeof(System.Int32)) : (int)0;
                results     = ProductProvider.GetByDocumentIdFromProductDocument(_documentId, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetByLocationIdFromProductInventory:
                _locationId = (values["LocationId"] != null) ? (System.Int16)EntityUtil.ChangeType(values["LocationId"], typeof(System.Int16)) : (short)0;
                results     = ProductProvider.GetByLocationIdFromProductInventory(_locationId, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetByProductPhotoIdFromProductProductPhoto:
                _productPhotoId = (values["ProductPhotoId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ProductPhotoId"], typeof(System.Int32)) : (int)0;
                results         = ProductProvider.GetByProductPhotoIdFromProductProductPhoto(_productPhotoId, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetByVendorIdFromProductVendor:
                _vendorId = (values["VendorId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["VendorId"], typeof(System.Int32)) : (int)0;
                results   = ProductProvider.GetByVendorIdFromProductVendor(_vendorId, this.StartIndex, this.PageSize, out count);
                break;

            case ProductSelectMethod.GetBySpecialOfferIdFromSpecialOfferProduct:
                _specialOfferId = (values["SpecialOfferId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["SpecialOfferId"], typeof(System.Int32)) : (int)0;
                results         = ProductProvider.GetBySpecialOfferIdFromSpecialOfferProduct(_specialOfferId, this.StartIndex, this.PageSize, out count);
                break;

            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <PurchaseOrderHeader> GetSelectData(out int count)
        {
            Hashtable values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <PurchaseOrderHeader> results = null;
            PurchaseOrderHeader         item;

            count = 0;

            System.Int32 _employeeId;
            System.Int32 _vendorId;
            System.Int32 _purchaseOrderId;
            System.Int32 _shipMethodId;

            switch (SelectMethod)
            {
            case PurchaseOrderHeaderSelectMethod.Get:
                PurchaseOrderHeaderKey entityKey = new PurchaseOrderHeaderKey();
                entityKey.Load(values);
                item    = PurchaseOrderHeaderProvider.Get(entityKey);
                results = new TList <PurchaseOrderHeader>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case PurchaseOrderHeaderSelectMethod.GetAll:
                results = PurchaseOrderHeaderProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case PurchaseOrderHeaderSelectMethod.GetPaged:
                results = PurchaseOrderHeaderProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case PurchaseOrderHeaderSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = PurchaseOrderHeaderProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = PurchaseOrderHeaderProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case PurchaseOrderHeaderSelectMethod.GetByPurchaseOrderId:
                _purchaseOrderId = (values["PurchaseOrderId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["PurchaseOrderId"], typeof(System.Int32)) : (int)0;
                item             = PurchaseOrderHeaderProvider.GetByPurchaseOrderId(_purchaseOrderId);
                results          = new TList <PurchaseOrderHeader>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case PurchaseOrderHeaderSelectMethod.GetByEmployeeId:
                _employeeId = (values["EmployeeId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["EmployeeId"], typeof(System.Int32)) : (int)0;
                results     = PurchaseOrderHeaderProvider.GetByEmployeeId(_employeeId, this.StartIndex, this.PageSize, out count);
                break;

            case PurchaseOrderHeaderSelectMethod.GetByVendorId:
                _vendorId = (values["VendorId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["VendorId"], typeof(System.Int32)) : (int)0;
                results   = PurchaseOrderHeaderProvider.GetByVendorId(_vendorId, this.StartIndex, this.PageSize, out count);
                break;

            // FK
            case PurchaseOrderHeaderSelectMethod.GetByShipMethodId:
                _shipMethodId = (values["ShipMethodId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ShipMethodId"], typeof(System.Int32)) : (int)0;
                results       = PurchaseOrderHeaderProvider.GetByShipMethodId(_shipMethodId, this.StartIndex, this.PageSize, out count);
                break;

            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationMap" /> class.
 /// </summary>
 public ConfigurationMap()
 {
     _innerHash = CollectionsUtil.CreateCaseInsensitiveHashtable();
 }
        /// <summary>
        /// TODO
        /// </summary>
        /// <param name="name">
        /// The name of the object that is having the value of one of its properties resolved.
        /// </param>
        /// <param name="definition">
        /// The definition of the named object.
        /// </param>
        /// <param name="argumentName">
        /// The name of the property the value of which is being resolved.
        /// </param>
        /// <param name="argumentValue">
        /// The value of the property that is being resolved.
        /// </param>
        private object ResolvePropertyValue(string name, IObjectDefinition definition, string argumentName, object argumentValue)
        {
            object resolvedValue = null;

            // we must check the argument value to see whether it requires a runtime
            // reference to another object to be resolved.
            // if it does, we'll attempt to instantiate the object and set the reference.
            if (RemotingServices.IsTransparentProxy(argumentValue))
            {
                resolvedValue = argumentValue;
            }
            else if (argumentValue is ICustomValueReferenceHolder)
            {
                resolvedValue = ((ICustomValueReferenceHolder)argumentValue).Resolve(objectFactory, name, definition, argumentName, argumentValue);
            }
            else if (argumentValue is ObjectDefinitionHolder)
            {
                // contains an IObjectDefinition with name and aliases...
                ObjectDefinitionHolder holder = (ObjectDefinitionHolder)argumentValue;
                resolvedValue = ResolveInnerObjectDefinition(name, holder.ObjectName, argumentName, holder.ObjectDefinition, definition.IsSingleton);
            }
            else if (argumentValue is IObjectDefinition)
            {
                // resolve plain IObjectDefinition, without contained name: use dummy name...
                IObjectDefinition def = (IObjectDefinition)argumentValue;
                resolvedValue = ResolveInnerObjectDefinition(name, "(inner object)", argumentName, def, definition.IsSingleton);
            }
            else if (argumentValue is RuntimeObjectReference)
            {
                RuntimeObjectReference roref = (RuntimeObjectReference)argumentValue;
                resolvedValue = ResolveReference(definition, name, argumentName, roref);
            }
            else if (argumentValue is ExpressionHolder)
            {
                ExpressionHolder expHolder = (ExpressionHolder)argumentValue;
                object           context   = null;
                IDictionary      variables = null;

                if (expHolder.Properties != null)
                {
                    PropertyValue contextProperty = expHolder.Properties.GetPropertyValue("Context");
                    context = contextProperty == null
                                  ? null
                                  : ResolveValueIfNecessary(name, definition, "Context",
                                                            contextProperty.Value);
                    PropertyValue variablesProperty = expHolder.Properties.GetPropertyValue("Variables");
                    object        vars = (variablesProperty == null
                                       ? null
                                       : ResolveValueIfNecessary(name, definition, "Variables",
                                                                 variablesProperty.Value));
                    if (vars is IDictionary)
                    {
                        variables = (IDictionary)vars;
                    }
                    else
                    {
                        if (vars != null)
                        {
                            throw new ArgumentException("'Variables' must resolve to an IDictionary");
                        }
                    }
                }

                if (variables == null)
                {
                    variables = CollectionsUtil.CreateCaseInsensitiveHashtable();
                }
                // add 'this' objectfactory reference to variables
                variables.Add(Expression.ReservedVariableNames.CurrentObjectFactory, objectFactory);

                resolvedValue = expHolder.Expression.GetValue(context, variables);
            }
            else if (argumentValue is IManagedCollection)
            {
                resolvedValue =
                    ((IManagedCollection)argumentValue).Resolve(name, definition, argumentName,
                                                                new ManagedCollectionElementResolver(ResolveValueIfNecessary));
            }
            else if (argumentValue is TypedStringValue)
            {
                TypedStringValue tsv = (TypedStringValue)argumentValue;
                try
                {
                    Type resolvedTargetType = ResolveTargetType(tsv);
                    if (resolvedTargetType != null)
                    {
                        resolvedValue = TypeConversionUtils.ConvertValueIfNecessary(tsv.TargetType, tsv.Value, null);
                    }
                    else
                    {
                        resolvedValue = tsv.Value;
                    }
                }
                catch (Exception ex)
                {
                    throw new ObjectCreationException(definition.ResourceDescription, name,
                                                      "Error converted typed String value for " + argumentName, ex);
                }
            }
            else
            {
                // no need to resolve value...
                resolvedValue = argumentValue;
            }
            return(resolvedValue);
        }
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <param name="values"></param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <Departments> GetSelectData(IDictionary values, out int count)
        {
            if (values == null || values.Count == 0)
            {
                values = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            }

            Hashtable           customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <Departments> results      = null;
            Departments         item;

            count = 0;

            System.String _departmentCode;

            switch (SelectMethod)
            {
            case DepartmentsSelectMethod.Get:
                DepartmentsKey entityKey = new DepartmentsKey();
                entityKey.Load(values);
                item    = DepartmentsProvider.Get(entityKey);
                results = new TList <Departments>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case DepartmentsSelectMethod.GetAll:
                results = DepartmentsProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case DepartmentsSelectMethod.GetPaged:
                results = DepartmentsProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case DepartmentsSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = DepartmentsProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = DepartmentsProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case DepartmentsSelectMethod.GetByDepartmentCode:
                _departmentCode = (values["DepartmentCode"] != null) ? (System.String)EntityUtil.ChangeType(values["DepartmentCode"], typeof(System.String)) : string.Empty;
                item            = DepartmentsProvider.GetByDepartmentCode(_departmentCode);
                results         = new TList <Departments>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            // FK
            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VcArgumentMap" />
 /// class.
 /// </summary>
 public VcArgumentMap()
 {
     _htArgs = CollectionsUtil.CreateCaseInsensitiveHashtable();
 }
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <Location> GetSelectData(out int count)
        {
            Hashtable        values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable        customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <Location> results      = null;
            Location         item;

            count = 0;

            System.String _name;
            System.Int16  _locationId;
            System.Int32  _productId;

            switch (SelectMethod)
            {
            case LocationSelectMethod.Get:
                LocationKey entityKey = new LocationKey();
                entityKey.Load(values);
                item    = LocationProvider.Get(entityKey);
                results = new TList <Location>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case LocationSelectMethod.GetAll:
                results = LocationProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case LocationSelectMethod.GetPaged:
                results = LocationProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case LocationSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = LocationProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = LocationProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case LocationSelectMethod.GetByLocationId:
                _locationId = (values["LocationId"] != null) ? (System.Int16)EntityUtil.ChangeType(values["LocationId"], typeof(System.Int16)) : (short)0;
                item        = LocationProvider.GetByLocationId(_locationId);
                results     = new TList <Location>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case LocationSelectMethod.GetByName:
                _name   = (values["Name"] != null) ? (System.String)EntityUtil.ChangeType(values["Name"], typeof(System.String)) : string.Empty;
                item    = LocationProvider.GetByName(_name);
                results = new TList <Location>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // FK
            // M:M
            case LocationSelectMethod.GetByProductIdFromProductInventory:
                _productId = (values["ProductId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ProductId"], typeof(System.Int32)) : (int)0;
                results    = LocationProvider.GetByProductIdFromProductInventory(_productId, this.StartIndex, this.PageSize, out count);
                break;

            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 11
0
 public TextCommandProcessorProvider(Connection connection)
     : base(connection)
 {
     commandProcessors = CollectionsUtil.CreateCaseInsensitiveHashtable();
 }
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <AwBuildVersion> GetSelectData(out int count)
        {
            Hashtable values               = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable customOutput         = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <AwBuildVersion> results = null;
            AwBuildVersion         item;

            count = 0;

            System.Byte _systemInformationId;

            switch (SelectMethod)
            {
            case AwBuildVersionSelectMethod.Get:
                AwBuildVersionKey entityKey = new AwBuildVersionKey();
                entityKey.Load(values);
                item    = AwBuildVersionProvider.Get(entityKey);
                results = new TList <AwBuildVersion>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case AwBuildVersionSelectMethod.GetAll:
                results = AwBuildVersionProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case AwBuildVersionSelectMethod.GetPaged:
                results = AwBuildVersionProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case AwBuildVersionSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = AwBuildVersionProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = AwBuildVersionProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case AwBuildVersionSelectMethod.GetBySystemInformationId:
                _systemInformationId = (values["SystemInformationId"] != null) ? (System.Byte)EntityUtil.ChangeType(values["SystemInformationId"], typeof(System.Byte)) : (byte)0;
                item    = AwBuildVersionProvider.GetBySystemInformationId(_systemInformationId);
                results = new TList <AwBuildVersion>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            // FK
            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 13
0
        /// <summary>
        /// Mutate the components.
        /// </summary>
        private void MutateComponents()
        {
            foreach (Wix.Component component in this.components)
            {
                SortedList indexedElements       = CollectionsUtil.CreateCaseInsensitiveSortedList();
                SortedList indexedRegistryValues = CollectionsUtil.CreateCaseInsensitiveSortedList();

                // index all the File elements
                foreach (Wix.File file in component[typeof(Wix.File)])
                {
                    indexedElements.Add(String.Concat("file/", file.Id), file);
                }

                // group all the registry values by the COM element they would correspond to and
                // create a COM element for each group
                foreach (Wix.RegistryValue registryValue in component[typeof(Wix.RegistryValue)])
                {
                    if (Wix.RegistryValue.ActionType.write == registryValue.Action && Wix.RegistryRootType.HKCR == registryValue.Root && Wix.RegistryValue.TypeType.@string == registryValue.Type)
                    {
                        string   index = null;
                        string[] parts = registryValue.Key.Split('\\');

                        // create a COM element for COM registration and index it
                        if (1 <= parts.Length)
                        {
                            if (0 == String.Compare(parts[0], "AppID", true))
                            {
                                // only work with GUID AppIds here
                                if (2 <= parts.Length && parts[1].StartsWith("{") && parts[1].EndsWith("}"))
                                {
                                    index = String.Concat(parts[0], '/', parts[1]);

                                    if (!indexedElements.Contains(index))
                                    {
                                        Wix.AppId appId = new Wix.AppId();
                                        appId.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
                                        indexedElements.Add(index, appId);
                                    }
                                }
                            }
                            else if (0 == String.Compare(parts[0], "CLSID", true))
                            {
                                if (2 <= parts.Length)
                                {
                                    index = String.Concat(parts[0], '/', parts[1]);

                                    if (!indexedElements.Contains(index))
                                    {
                                        Wix.Class wixClass = new Wix.Class();
                                        wixClass.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
                                        indexedElements.Add(index, wixClass);
                                    }
                                }
                            }
                            else if (0 == String.Compare(parts[0], "Component Categories", true))
                            {
                                // TODO: add support for this to the compiler
                            }
                            else if (0 == String.Compare(parts[0], "Interface", true))
                            {
                                if (2 <= parts.Length)
                                {
                                    index = String.Concat(parts[0], '/', parts[1]);

                                    if (!indexedElements.Contains(index))
                                    {
                                        Wix.Interface wixInterface = new Wix.Interface();
                                        wixInterface.Id = parts[1].ToUpper(CultureInfo.InvariantCulture);
                                        indexedElements.Add(index, wixInterface);
                                    }
                                }
                            }
                            else if (0 == String.Compare(parts[0], "TypeLib"))
                            {
                                if (3 <= parts.Length)
                                {
                                    // use a special index to ensure progIds are processed before classes
                                    index = String.Concat(".typelib/", parts[1], '/', parts[2]);

                                    if (!indexedElements.Contains(index))
                                    {
                                        try
                                        {
                                            // TODO: properly handle hexadecimal in version
                                            Version version = new Version(parts[2]);

                                            Wix.TypeLib typeLib = new Wix.TypeLib();
                                            typeLib.Id           = parts[1].ToUpper(CultureInfo.InvariantCulture);
                                            typeLib.MajorVersion = version.Major;
                                            typeLib.MinorVersion = version.Minor;
                                            indexedElements.Add(index, typeLib);
                                        }
                                        catch // not a valid type library registry value
                                        {
                                            index = null;
                                        }
                                    }
                                }
                            }
                            else if (parts[0].StartsWith("."))
                            {
                                // extension
                            }
                            else // ProgId (hopefully)
                            {
                                // use a special index to ensure progIds are processed before classes
                                index = String.Concat(".progid/", parts[0]);

                                if (!indexedElements.Contains(index))
                                {
                                    Wix.ProgId progId = new Wix.ProgId();
                                    progId.Id = parts[0];
                                    indexedElements.Add(index, progId);
                                }
                            }
                        }

                        // index the RegistryValue element according to the COM element it corresponds to
                        if (null != index)
                        {
                            SortedList registryValues = (SortedList)indexedRegistryValues[index];

                            if (null == registryValues)
                            {
                                registryValues = CollectionsUtil.CreateCaseInsensitiveSortedList();
                                indexedRegistryValues.Add(index, registryValues);
                            }

                            registryValues.Add(String.Concat(registryValue.Key, '/', registryValue.Name), registryValue);
                        }
                    }
                }

                // set various values on the COM elements from their corresponding registry values
                Hashtable indexedProcessedRegistryValues = new Hashtable();
                foreach (DictionaryEntry entry in indexedRegistryValues)
                {
                    Wix.ISchemaElement element        = (Wix.ISchemaElement)indexedElements[entry.Key];
                    string             parentIndex    = null;
                    SortedList         registryValues = (SortedList)entry.Value;

                    // element-specific variables (for really tough situations)
                    string classAppId        = null;
                    bool   threadingModelSet = false;

                    foreach (Wix.RegistryValue registryValue in registryValues.Values)
                    {
                        string[] parts     = registryValue.Key.ToLower(CultureInfo.InvariantCulture).Split('\\');
                        bool     processed = false;

                        if (element is Wix.AppId)
                        {
                            Wix.AppId appId = (Wix.AppId)element;

                            if (2 == parts.Length)
                            {
                                if (null == registryValue.Name)
                                {
                                    appId.Description = registryValue.Value;
                                    processed         = true;
                                }
                            }
                        }
                        else if (element is Wix.Class)
                        {
                            Wix.Class wixClass = (Wix.Class)element;

                            if (2 == parts.Length)
                            {
                                if (null == registryValue.Name)
                                {
                                    wixClass.Description = registryValue.Value;
                                    processed            = true;
                                }
                                else if (0 == String.Compare(registryValue.Name, "AppID", true))
                                {
                                    classAppId = registryValue.Value;
                                    processed  = true;
                                }
                            }
                            else if (3 == parts.Length)
                            {
                                Wix.Class.ContextType contextType = Wix.Class.ContextType.None;

                                switch (parts[2])
                                {
                                case "inprochandler":
                                    if (null == registryValue.Name)
                                    {
                                        if (null == wixClass.Handler)
                                        {
                                            wixClass.Handler = "1";
                                            processed        = true;
                                        }
                                        else if ("2" == wixClass.Handler)
                                        {
                                            wixClass.Handler = "3";
                                            processed        = true;
                                        }
                                    }
                                    break;

                                case "inprochandler32":
                                    if (null == registryValue.Name)
                                    {
                                        if (null == wixClass.Handler)
                                        {
                                            wixClass.Handler = "2";
                                            processed        = true;
                                        }
                                        else if ("1" == wixClass.Handler)
                                        {
                                            wixClass.Handler = "3";
                                            processed        = true;
                                        }
                                    }
                                    break;

                                case "inprocserver":
                                    contextType = Wix.Class.ContextType.InprocServer;
                                    break;

                                case "inprocserver32":
                                    contextType = Wix.Class.ContextType.InprocServer32;
                                    break;

                                case "localserver":
                                    contextType = Wix.Class.ContextType.LocalServer;
                                    break;

                                case "localserver32":
                                    contextType = Wix.Class.ContextType.LocalServer32;
                                    break;

                                case "progid":
                                    if (null == registryValue.Name)
                                    {
                                        Wix.ProgId progId = (Wix.ProgId)indexedElements[String.Concat(".progid/", registryValue.Value)];

                                        // verify that the versioned ProgId appears under this Class element
                                        // if not, toss the entire element
                                        if (null == progId || wixClass != progId.ParentElement)
                                        {
                                            element = null;
                                        }
                                        else
                                        {
                                            processed = true;
                                        }
                                    }
                                    break;

                                case "typelib":
                                    if (null == registryValue.Name)
                                    {
                                        foreach (DictionaryEntry indexedEntry in indexedElements)
                                        {
                                            string             key             = (string)indexedEntry.Key;
                                            Wix.ISchemaElement possibleTypeLib = (Wix.ISchemaElement)indexedEntry.Value;

                                            if (key.StartsWith(".typelib/") &&
                                                0 == String.Compare(key, 9, registryValue.Value, 0, registryValue.Value.Length, true))
                                            {
                                                // ensure the TypeLib is nested under the same thing we want the Class under
                                                if (null == parentIndex || indexedElements[parentIndex] == possibleTypeLib.ParentElement)
                                                {
                                                    parentIndex = key;
                                                    processed   = true;
                                                }
                                            }
                                        }
                                    }
                                    break;

                                case "version":
                                    if (null == registryValue.Name)
                                    {
                                        wixClass.Version = registryValue.Value;
                                        processed        = true;
                                    }
                                    break;

                                case "versionindependentprogid":
                                    if (null == registryValue.Name)
                                    {
                                        Wix.ProgId progId = (Wix.ProgId)indexedElements[String.Concat(".progid/", registryValue.Value)];

                                        // verify that the version independent ProgId appears somewhere
                                        // under this Class element - if not, toss the entire element
                                        if (null == progId || wixClass != progId.ParentElement)
                                        {
                                            // check the parent of the parent
                                            if (null == progId || null == progId.ParentElement || wixClass != progId.ParentElement.ParentElement)
                                            {
                                                element = null;
                                            }
                                        }

                                        processed = true;
                                    }
                                    break;
                                }

                                if (Wix.Class.ContextType.None != contextType)
                                {
                                    wixClass.Context |= contextType;

                                    if (null == registryValue.Name)
                                    {
                                        if ((registryValue.Value.StartsWith("[!") || registryValue.Value.StartsWith("[#")) && registryValue.Value.EndsWith("]"))
                                        {
                                            parentIndex = String.Concat("file/", registryValue.Value.Substring(2, registryValue.Value.Length - 3));
                                            processed   = true;
                                        }
                                    }
                                    else if (0 == String.Compare(registryValue.Name, "ThreadingModel", true))
                                    {
                                        Wix.Class.ThreadingModelType threadingModel;

                                        switch (registryValue.Value.ToLower(CultureInfo.InvariantCulture))
                                        {
                                        case "apartment":
                                            threadingModel = Wix.Class.ThreadingModelType.apartment;
                                            processed      = true;
                                            break;

                                        case "both":
                                            threadingModel = Wix.Class.ThreadingModelType.both;
                                            processed      = true;
                                            break;

                                        case "free":
                                            threadingModel = Wix.Class.ThreadingModelType.free;
                                            processed      = true;
                                            break;

                                        case "neutral":
                                            threadingModel = Wix.Class.ThreadingModelType.neutral;
                                            processed      = true;
                                            break;

                                        case "rental":
                                            threadingModel = Wix.Class.ThreadingModelType.rental;
                                            processed      = true;
                                            break;

                                        case "single":
                                            threadingModel = Wix.Class.ThreadingModelType.single;
                                            processed      = true;
                                            break;

                                        default:
                                            continue;
                                        }

                                        if (!threadingModelSet || wixClass.ThreadingModel == threadingModel)
                                        {
                                            wixClass.ThreadingModel = threadingModel;
                                            threadingModelSet       = true;
                                        }
                                        else
                                        {
                                            element = null;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else if (element is Wix.Interface)
                        {
                            Wix.Interface wixInterface = (Wix.Interface)element;

                            if (2 == parts.Length && null == registryValue.Name)
                            {
                                wixInterface.Name = registryValue.Value;
                                processed         = true;
                            }
                            else if (3 == parts.Length)
                            {
                                switch (parts[2])
                                {
                                case "proxystubclsid":
                                    if (null == registryValue.Name)
                                    {
                                        wixInterface.ProxyStubClassId = registryValue.Value.ToUpper(CultureInfo.InvariantCulture);
                                        processed = true;
                                    }
                                    break;

                                case "proxystubclsid32":
                                    if (null == registryValue.Name)
                                    {
                                        wixInterface.ProxyStubClassId32 = registryValue.Value.ToUpper(CultureInfo.InvariantCulture);
                                        processed = true;
                                    }
                                    break;

                                case "nummethods":
                                    if (null == registryValue.Name)
                                    {
                                        wixInterface.NumMethods = Convert.ToInt32(registryValue.Value, CultureInfo.InvariantCulture);
                                        processed = true;
                                    }
                                    break;

                                case "typelib":
                                    if (0 == String.Compare("Version", registryValue.Name, true))
                                    {
                                        parentIndex = String.Concat(parentIndex, registryValue.Value);
                                        processed   = true;
                                    }
                                    else if (null == registryValue.Name)     // TypeLib guid
                                    {
                                        parentIndex = String.Concat(".typelib/", registryValue.Value, '/', parentIndex);
                                        processed   = true;
                                    }
                                    break;
                                }
                            }
                        }
                        else if (element is Wix.ProgId)
                        {
                            Wix.ProgId progId = (Wix.ProgId)element;

                            if (null == registryValue.Name)
                            {
                                if (1 == parts.Length)
                                {
                                    progId.Description = registryValue.Value;
                                    processed          = true;
                                }
                                else if (2 == parts.Length)
                                {
                                    if (0 == String.Compare(parts[1], "CLSID", true))
                                    {
                                        parentIndex = String.Concat("CLSID/", registryValue.Value);
                                        processed   = true;
                                    }
                                    else if (0 == String.Compare(parts[1], "CurVer", true))
                                    {
                                        // this registry value should usually be processed second so the
                                        // version independent ProgId should be under the versioned one
                                        parentIndex = String.Concat(".progid/", registryValue.Value);
                                        processed   = true;
                                    }
                                }
                            }
                        }
                        else if (element is Wix.TypeLib)
                        {
                            Wix.TypeLib typeLib = (Wix.TypeLib)element;

                            if (null == registryValue.Name)
                            {
                                if (3 == parts.Length)
                                {
                                    typeLib.Description = registryValue.Value;
                                    processed           = true;
                                }
                                else if (4 == parts.Length)
                                {
                                    switch (parts[3].ToLower(CultureInfo.InvariantCulture))
                                    {
                                    case "flags":
                                        int flags = Convert.ToInt32(registryValue.Value, CultureInfo.InvariantCulture);

                                        if (0x1 == (flags & 0x1))
                                        {
                                            typeLib.Restricted = Wix.YesNoType.yes;
                                        }

                                        if (0x2 == (flags & 0x2))
                                        {
                                            typeLib.Control = Wix.YesNoType.yes;
                                        }

                                        if (0x4 == (flags & 0x4))
                                        {
                                            typeLib.Hidden = Wix.YesNoType.yes;
                                        }

                                        if (0x8 == (flags & 0x8))
                                        {
                                            typeLib.HasDiskImage = Wix.YesNoType.yes;
                                        }

                                        processed = true;
                                        break;

                                    case "helpdir":
                                        if (registryValue.Value.StartsWith("[") && (registryValue.Value.EndsWith("]") || registryValue.Value.EndsWith("]\\")))
                                        {
                                            typeLib.HelpDirectory = registryValue.Value.Substring(1, registryValue.Value.LastIndexOf(']') - 1);
                                            processed             = true;
                                        }
                                        break;
                                    }
                                }
                                else if (5 == parts.Length && 0 == String.Compare("win32", parts[4], true))
                                {
                                    typeLib.Language = Convert.ToInt32(parts[3], CultureInfo.InvariantCulture);

                                    if ((registryValue.Value.StartsWith("[!") || registryValue.Value.StartsWith("[#")) && registryValue.Value.EndsWith("]"))
                                    {
                                        parentIndex = String.Concat("file/", registryValue.Value.Substring(2, registryValue.Value.Length - 3));
                                    }

                                    processed = true;
                                }
                            }
                        }

                        // index the processed registry values by their corresponding COM element
                        if (processed)
                        {
                            indexedProcessedRegistryValues.Add(registryValue, element);
                        }
                    }

                    // parent the COM element
                    if (null != element)
                    {
                        if (null != parentIndex)
                        {
                            Wix.IParentElement parentElement = (Wix.IParentElement)indexedElements[parentIndex];

                            if (null != parentElement)
                            {
                                parentElement.AddChild(element);
                            }
                        }
                        else
                        {
                            component.AddChild(element);
                        }

                        // special handling for AppID since it doesn't fit the general model
                        if (null != classAppId)
                        {
                            Wix.AppId appId = (Wix.AppId)indexedElements[String.Concat("AppID/", classAppId)];

                            // move the Class element under the AppId (and put the AppId under its old parent)
                            if (null != appId)
                            {
                                // move the AppId element
                                ((Wix.IParentElement)appId.ParentElement).RemoveChild(appId);
                                ((Wix.IParentElement)element.ParentElement).AddChild(appId);

                                // move the Class element
                                ((Wix.IParentElement)element.ParentElement).RemoveChild(element);
                                appId.AddChild(element);
                            }
                        }
                    }
                }

                // remove the RegistryValue elements which were converted into COM elements
                // that were successfully nested under the Component element
                foreach (DictionaryEntry entry in indexedProcessedRegistryValues)
                {
                    Wix.ISchemaElement element       = (Wix.ISchemaElement)entry.Value;
                    Wix.RegistryValue  registryValue = (Wix.RegistryValue)entry.Key;

                    while (null != element)
                    {
                        if (element == component)
                        {
                            ((Wix.IParentElement)registryValue.ParentElement).RemoveChild(registryValue);
                            break;
                        }

                        element = element.ParentElement;
                    }
                }
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GacCache"/> class in
 /// the context of the given <see cref="Project" />.
 /// </summary>
 public GacCache(Project project)
 {
     _project       = project;
     _gacQueryCache = CollectionsUtil.CreateCaseInsensitiveHashtable();
     RecreateDomain();
 }
Esempio n. 15
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <JobCandidate> GetSelectData(out int count)
        {
            Hashtable            values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable            customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <JobCandidate> results      = null;
            JobCandidate         item;

            count = 0;

            System.Int32?_employeeId_nullable;
            System.Int32 _jobCandidateId;

            switch (SelectMethod)
            {
            case JobCandidateSelectMethod.Get:
                JobCandidateKey entityKey = new JobCandidateKey();
                entityKey.Load(values);
                item    = JobCandidateProvider.Get(entityKey);
                results = new TList <JobCandidate>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case JobCandidateSelectMethod.GetAll:
                results = JobCandidateProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case JobCandidateSelectMethod.GetPaged:
                results = JobCandidateProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case JobCandidateSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = JobCandidateProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = JobCandidateProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case JobCandidateSelectMethod.GetByJobCandidateId:
                _jobCandidateId = (values["JobCandidateId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["JobCandidateId"], typeof(System.Int32)) : (int)0;
                item            = JobCandidateProvider.GetByJobCandidateId(_jobCandidateId);
                results         = new TList <JobCandidate>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case JobCandidateSelectMethod.GetByEmployeeId:
                _employeeId_nullable = (System.Int32?)EntityUtil.ChangeType(values["EmployeeId"], typeof(System.Int32?));
                results = JobCandidateProvider.GetByEmployeeId(_employeeId_nullable, this.StartIndex, this.PageSize, out count);
                break;

            // FK
            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 16
0
        internal BuildItem(XmlElement itemElement, BuildItemGroup parentItemGroup)
        {
            child_items            = new List <BuildItem> ();
            isImported             = parentItemGroup.IsImported;
            unevaluatedMetadata    = CollectionsUtil.CreateCaseInsensitiveHashtable();
            evaluatedMetadata      = CollectionsUtil.CreateCaseInsensitiveHashtable();
            this.parent_item_group = parentItemGroup;

            this.itemElement = itemElement;
            isDynamic        = parentItemGroup.IsDynamic;

            if (IsDynamic)
            {
                if (!string.IsNullOrEmpty(Remove))
                {
                    if (!string.IsNullOrEmpty(Include) || !string.IsNullOrEmpty(Exclude))
                    {
                        throw new InvalidProjectFileException(string.Format("The attribute \"Remove\" in element <{0}> is unrecognized.", Name));
                    }
                    if (itemElement.HasChildNodes)
                    {
                        throw new InvalidProjectFileException("Children are not allowed below an item remove element.");
                    }
                }
                if (string.IsNullOrEmpty(Include) && !string.IsNullOrEmpty(Exclude))
                {
                    throw new InvalidProjectFileException(string.Format("The attribute \"Exclude\" in element <{0}> is unrecognized.", Name));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Include))
                {
                    throw new InvalidProjectFileException(string.Format("The required attribute \"Include\" is missing from element <{0}>.", Name));
                }
                if (!string.IsNullOrEmpty(Remove))
                {
                    throw new InvalidProjectFileException(string.Format("The attribute \"Remove\" in element <{0}> is unrecognized.", Name));
                }
            }

            foreach (XmlAttribute attr in itemElement.Attributes)
            {
                if (attr.Name == "Include" || attr.Name == "Exclude" || attr.Name == "Condition")
                {
                    continue;
                }
                if (!IsDynamic)
                {
                    throw new InvalidProjectFileException(string.Format("The attribute \"{0}\" in element <{1}> is unrecognized.", attr.Name, Name));
                }

                switch (attr.Name)
                {
                case "Remove":
                    Remove = attr.Value;
                    break;

                case "KeepDuplicates":
                    KeepDuplicates = bool.Parse(attr.Value);
                    break;

                case "RemoveMetadata":
                    removeMetadata = attr.Value;
                    break;

                case "KeepMetadata":
                    keepMetadata = attr.Value;
                    break;

                default:
                    throw new InvalidProjectFileException(string.Format("The attribute \"{0}\" in element <{1}> is unrecognized.", attr.Name, Name));
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <Shift> GetSelectData(out int count)
        {
            Hashtable     values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable     customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <Shift> results      = null;
            Shift         item;

            count = 0;

            System.String   _name;
            System.DateTime _startTime;
            System.DateTime _endTime;
            System.Byte     _shiftId;

            switch (SelectMethod)
            {
            case ShiftSelectMethod.Get:
                ShiftKey entityKey = new ShiftKey();
                entityKey.Load(values);
                item    = ShiftProvider.Get(entityKey);
                results = new TList <Shift>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case ShiftSelectMethod.GetAll:
                results = ShiftProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case ShiftSelectMethod.GetPaged:
                results = ShiftProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case ShiftSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = ShiftProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = ShiftProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case ShiftSelectMethod.GetByShiftId:
                _shiftId = (values["ShiftId"] != null) ? (System.Byte)EntityUtil.ChangeType(values["ShiftId"], typeof(System.Byte)) : (byte)0;
                item     = ShiftProvider.GetByShiftId(_shiftId);
                results  = new TList <Shift>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case ShiftSelectMethod.GetByName:
                _name   = (values["Name"] != null) ? (System.String)EntityUtil.ChangeType(values["Name"], typeof(System.String)) : string.Empty;
                item    = ShiftProvider.GetByName(_name);
                results = new TList <Shift>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case ShiftSelectMethod.GetByStartTimeEndTime:
                _startTime = (values["StartTime"] != null) ? (System.DateTime)EntityUtil.ChangeType(values["StartTime"], typeof(System.DateTime)) : DateTime.MinValue;
                _endTime   = (values["EndTime"] != null) ? (System.DateTime)EntityUtil.ChangeType(values["EndTime"], typeof(System.DateTime)) : DateTime.MinValue;
                item       = ShiftProvider.GetByStartTimeEndTime(_startTime, _endTime);
                results    = new TList <Shift>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // FK
            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 18
0
 public TaskItem()
 {
     this.itemSpec = String.Empty;
     this.metadata = CollectionsUtil.CreateCaseInsensitiveHashtable();
 }
Esempio n. 19
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <param name="values"></param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <Students> GetSelectData(IDictionary values, out int count)
        {
            if (values == null || values.Count == 0)
            {
                values = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            }

            Hashtable        customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <Students> results      = null;
            Students         item;

            count = 0;

            System.Int32 _id;
            System.Int32 _classId;

            switch (SelectMethod)
            {
            case StudentsSelectMethod.Get:
                StudentsKey entityKey = new StudentsKey();
                entityKey.Load(values);
                item    = StudentsProvider.Get(GetTransactionManager(), entityKey);
                results = new TList <Students>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case StudentsSelectMethod.GetAll:
                results = StudentsProvider.GetAll(GetTransactionManager(), StartIndex, PageSize, out count);
                break;

            case StudentsSelectMethod.GetPaged:
                results = StudentsProvider.GetPaged(GetTransactionManager(), WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case StudentsSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = StudentsProvider.Find(GetTransactionManager(), FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = StudentsProvider.Find(GetTransactionManager(), WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case StudentsSelectMethod.GetById:
                _id     = (values["Id"] != null) ? (System.Int32)EntityUtil.ChangeType(values["Id"], typeof(System.Int32)) : (int)0;
                item    = StudentsProvider.GetById(GetTransactionManager(), _id);
                results = new TList <Students>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            // FK
            case StudentsSelectMethod.GetByClassId:
                _classId = (values["ClassId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ClassId"], typeof(System.Int32)) : (int)0;
                results  = StudentsProvider.GetByClassId(GetTransactionManager(), _classId, this.StartIndex, this.PageSize, out count);
                break;

            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 20
0
        /// <summary>
        /// Parses content-type header values of the form
        ///		mainValue;param1=value1;param2=value2
        /// but taking into account folding whitespace, comments, quoting,
        /// quoted-char, and all the other stuff that RFC2045/RFC2822
        /// force us to deal with.
        ///
        /// To get the mainValue, look for the key "" in the result table.
        /// </summary>
        public static IDictionary ParseContentType(string contentType, bool caseInsensitive)
        {
            IDictionary result = new Hashtable();

            // get main value
            string[] mainAndRest = contentType.Split(new char[] { ';' }, 2);
            result[""] = mainAndRest[0].Trim().ToLowerInvariant();
            if (mainAndRest.Length > 1)
            {
                char[]        chars      = mainAndRest[1].ToCharArray();
                StringBuilder paramName  = new StringBuilder();
                StringBuilder paramValue = new StringBuilder();

                const byte READY_FOR_NAME  = 0;
                const byte IN_NAME         = 1;
                const byte READY_FOR_VALUE = 2;
                const byte IN_VALUE        = 3;
                const byte IN_QUOTED_VALUE = 4;
                const byte VALUE_DONE      = 5;
                const byte ERROR           = 99;

                byte state = READY_FOR_NAME;
                for (int i = 0; i < chars.Length; i++)
                {
                    char c = chars[i];

                    switch (state)
                    {
                    case ERROR:
                        if (c == ';')
                        {
                            state = READY_FOR_NAME;
                        }
                        break;

                    case READY_FOR_NAME:
                        if (c == '=')
                        {
                            Debug.Fail("Expected header param name, got '='");
                            state = ERROR;
                            break;
                        }

                        paramName  = new StringBuilder();
                        paramValue = new StringBuilder();

                        state = IN_NAME;
                        goto case IN_NAME;

                    case IN_NAME:
                        if (c == '=')
                        {
                            if (paramName.Length == 0)
                            {
                                state = ERROR;
                            }
                            else
                            {
                                state = READY_FOR_VALUE;
                            }
                            break;
                        }

                        // not '='... just add to name
                        paramName.Append(c);
                        break;

                    case READY_FOR_VALUE:
                        bool gotoCaseInValue = false;
                        switch (c)
                        {
                        case ' ':
                        case '\t':
                            break;                                      // ignore spaces, especially before '"'

                        case '"':
                            state = IN_QUOTED_VALUE;
                            break;

                        default:
                            state           = IN_VALUE;
                            gotoCaseInValue = true;
                            break;
                        }
                        if (gotoCaseInValue)
                        {
                            goto case IN_VALUE;
                        }
                        else
                        {
                            break;
                        }

                    case IN_VALUE:
                        switch (c)
                        {
                        case ';':
                            result[paramName.ToString().Trim()] = paramValue.ToString().Trim();
                            state = READY_FOR_NAME;
                            break;

                        default:
                            paramValue.Append(c);
                            break;
                        }
                        break;

                    case IN_QUOTED_VALUE:
                        switch (c)
                        {
                        case '"':
                            // don't trim quoted strings; the spaces could be intentional.
                            result[paramName.ToString().Trim()] = paramValue.ToString();
                            state = VALUE_DONE;
                            break;

                        case '\\':
                            // quoted-char
                            if (i == chars.Length - 1)
                            {
                                state = ERROR;
                            }
                            else
                            {
                                i++;
                                paramValue.Append(chars[i]);
                            }
                            break;

                        default:
                            paramValue.Append(c);
                            break;
                        }
                        break;

                    case VALUE_DONE:
                        switch (c)
                        {
                        case ';':
                            state = READY_FOR_NAME;
                            break;

                        case ' ':
                        case '\t':
                            break;

                        default:
                            state = ERROR;
                            break;
                        }
                        break;
                    }
                }

                // done looping.  check if anything is left over.
                if (state == IN_VALUE || state == READY_FOR_VALUE)
                {
                    result[paramName.ToString().Trim()] = paramValue.ToString().Trim();
                }
            }

            if (caseInsensitive)
            {
                return(CollectionsUtil.CreateCaseInsensitiveHashtable(result));
            }
            else
            {
                return(result);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Gets a collection of Entity objects based on the value of the SelectMethod property.
        /// </summary>
        /// <param name="count">The total number of rows in the DataSource.</param>
        /// <returns>A collection of Entity objects.</returns>
        protected override IList <TransactionHistoryArchive> GetSelectData(out int count)
        {
            Hashtable values       = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
            Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
            IList <TransactionHistoryArchive> results = null;
            TransactionHistoryArchive         item;

            count = 0;

            System.Int32 _productId;
            System.Int32 _referenceOrderId;
            System.Int32 _referenceOrderLineId;
            System.Int32 _transactionId;

            switch (SelectMethod)
            {
            case TransactionHistoryArchiveSelectMethod.Get:
                TransactionHistoryArchiveKey entityKey = new TransactionHistoryArchiveKey();
                entityKey.Load(values);
                item    = TransactionHistoryArchiveProvider.Get(entityKey);
                results = new TList <TransactionHistoryArchive>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            case TransactionHistoryArchiveSelectMethod.GetAll:
                results = TransactionHistoryArchiveProvider.GetAll(StartIndex, PageSize, out count);
                break;

            case TransactionHistoryArchiveSelectMethod.GetPaged:
                results = TransactionHistoryArchiveProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
                break;

            case TransactionHistoryArchiveSelectMethod.Find:
                if (FilterParameters != null)
                {
                    results = TransactionHistoryArchiveProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
                }
                else
                {
                    results = TransactionHistoryArchiveProvider.Find(WhereClause, StartIndex, PageSize, out count);
                }
                break;

            // PK
            case TransactionHistoryArchiveSelectMethod.GetByTransactionId:
                _transactionId = (values["TransactionId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["TransactionId"], typeof(System.Int32)) : (int)0;
                item           = TransactionHistoryArchiveProvider.GetByTransactionId(_transactionId);
                results        = new TList <TransactionHistoryArchive>();
                if (item != null)
                {
                    results.Add(item);
                }
                count = results.Count;
                break;

            // IX
            case TransactionHistoryArchiveSelectMethod.GetByProductId:
                _productId = (values["ProductId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ProductId"], typeof(System.Int32)) : (int)0;
                results    = TransactionHistoryArchiveProvider.GetByProductId(_productId, this.StartIndex, this.PageSize, out count);
                break;

            case TransactionHistoryArchiveSelectMethod.GetByReferenceOrderIdReferenceOrderLineId:
                _referenceOrderId     = (values["ReferenceOrderId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ReferenceOrderId"], typeof(System.Int32)) : (int)0;
                _referenceOrderLineId = (values["ReferenceOrderLineId"] != null) ? (System.Int32)EntityUtil.ChangeType(values["ReferenceOrderLineId"], typeof(System.Int32)) : (int)0;
                results = TransactionHistoryArchiveProvider.GetByReferenceOrderIdReferenceOrderLineId(_referenceOrderId, _referenceOrderLineId, this.StartIndex, this.PageSize, out count);
                break;

            // FK
            // M:M
            // Custom
            default:
                break;
            }

            if (results != null && count < 1)
            {
                count = results.Count;

                if (!String.IsNullOrEmpty(CustomMethodRecordCountParamName))
                {
                    object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));

                    if (objCustomCount != null)
                    {
                        count = (int)objCustomCount;
                    }
                }
            }

            return(results);
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationMap" />
 /// class with the specified initial capacity.
 /// </summary>
 /// <param name="capacity">The appropriate number of entries that the <see cref="ConfigurationMap" /> can initially contain.</param>
 public ConfigurationMap(int capacity)
 {
     _innerHash = CollectionsUtil.CreateCaseInsensitiveHashtable(capacity);
 }
Esempio n. 23
0
 public XmlSerializerNamespaces()
 {
     namespaces = CollectionsUtil.CreateCaseInsensitiveHashtable();
     prefixes   = CollectionsUtil.CreateCaseInsensitiveHashtable();
 }