private NameObjectCollection PrepareWxeFunctionParameters(int listIndex, IBusinessObject businessObject)
        {
            NameObjectCollection parameters = new NameObjectCollection();

            parameters["index"]  = listIndex;
            parameters["object"] = businessObject;
            if (businessObject is IBusinessObjectWithIdentity)
            {
                parameters["id"] = ((IBusinessObjectWithIdentity)businessObject).UniqueIdentifier;
            }
            else
            {
                parameters["id"] = null;
            }
            if (OwnerControl != null)
            {
                if (OwnerControl.DataSource != null && OwnerControl.Value != null)
                {
                    parameters["parent"] = OwnerControl.DataSource.BusinessObject;
                }
                if (OwnerControl.Property != null)
                {
                    parameters["parentproperty"] = OwnerControl.Property;
                }
            }

            return(parameters);
        }
Ejemplo n.º 2
0
        public void SetIris(IrisMode mode, int level)
        {
            int    irisModeValue = 0;
            string propertyName  = null;

            switch (mode)
            {
            case IrisMode.Auto:
                irisModeValue = 0;
                propertyName  = _IrisAutoLevel;
                break;

            case IrisMode.Manual:
                irisModeValue = 1;
                propertyName  = _IrisManualLevel;
                break;

            default:
                throw new InvalidEnumArgumentException("mode is invalid");
                break;
            }


            var nameValues = new NameObjectCollection();

            nameValues.Add(_IrisMode, irisModeValue);
            nameValues.Add(propertyName, level);

            var uri = BuildUri(nameValues);

            SetCameraProperty(uri);
        }
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            var srcValue = srcValues[mapping.SourceProperty] ?? Common.EmptyString;
            var targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (typeof(DateTime).IsAssignableFrom(srcValue.GetType()))
            {
                if (string.IsNullOrEmpty(targetString) == false)
                {
                    DateTime left = (DateTime)srcValue;
                    DateTime right = DateTime.Parse(targetString);

                    return left.Equals(right); //完全精度匹配(几乎不可能实现)

                }
                else
                    return false; // 左边对象有值,而右边对象没值
            }
            else if (srcValue is string)
            {
                return ((string)srcValue) == targetString;
            }
            else
            {
                return mapping.Parameters["sourceDefaultValue"] == targetString; //源对象为null或其他情形
            }
        }
        public void NameObjectCollection_Constructor_Default_UsesKeyComparer()
        {
            NameObjectCollection<int> collection = new NameObjectCollection<int>(StringComparer.OrdinalIgnoreCase);
            collection.Add("test", 42);

            Assert.That(collection.Get("TEST"), Is.EqualTo(42));
        }
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            var srcValue     = srcValues[mapping.SourceProperty] ?? Common.EmptyString;
            var targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (typeof(bool).IsAssignableFrom(srcValue.GetType()))
            {
                if (string.IsNullOrEmpty(targetString) == false)
                {
                    return(((bool)srcValue).Equals(bool.Parse(targetString)));
                }
                else
                {
                    return(false); // 左边对象有值,而右边对象没值
                }
            }
            else if (srcValue is string)
            {
                return(string.Equals((string)srcValue, (string)targetString, StringComparison.OrdinalIgnoreCase));
            }
            else
            {
                return(mapping.Parameters["sourceDefaultValue"] == targetString); //源对象为null或其他情形
            }
        }
Ejemplo n.º 6
0
        private static NameObjectCollection ParseCameraProperties(System.IO.Stream replyStream)
        {
            var nameValues = new NameObjectCollection();

            using (StreamReader rdr = new StreamReader(replyStream))
            {
                while (true)
                {
                    var line = rdr.ReadLine();

                    if (line == null)//end of stream
                    {
                        break;
                    }

                    if (ShouldSkip(line))
                    {
                        continue;
                    }

                    try
                    {
                        var keyValue = ParseSemicommaSplittedLine(line);
                        if (!nameValues.ContainsKey(keyValue.Key))
                        {
                            nameValues.Add(keyValue.Key, keyValue.Value);
                        }
                    }
                    catch (System.ArgumentException) {}
                }

                return(nameValues);
            }
        }
 /// <summary> Copy a single callee parameter back to a caller variable. </summary>
 public void CopyToCaller(string actualParameterName, NameObjectCollection calleeVariables, NameObjectCollection callerVariables)
 {
     if (_direction != WxeParameterDirection.In)
     {
         CopyParameter(_name, calleeVariables, actualParameterName, callerVariables, false);
     }
 }
Ejemplo n.º 8
0
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            string enumType = mapping.Parameters["enumType"];

            if (string.IsNullOrEmpty(enumType))
            {
                throw new System.Configuration.ConfigurationErrorsException("配置EnumPropertyComparer时,必须指定enumType属性");
            }

            var type = Type.GetType(enumType);

            if (type == null)
            {
                throw new System.Configuration.ConfigurationErrorsException("未找到指定的枚举类型 " + enumType);
            }

            object srcValue = srcValues[mapping.SourceProperty];

            string targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (string.IsNullOrEmpty(targetString) == false)
            {
                return(srcValue.Equals(int.Parse(targetString)));
            }
            else
            {
                return(false);
            }
        }
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            var srcValue = srcValues[mapping.SourceProperty] ?? Common.EmptyString;
            var targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (typeof(float).IsAssignableFrom(srcValue.GetType()))
            {
                if (string.IsNullOrEmpty(targetString) == false)
                {
                    float left = (float)srcValue;
                    float right = float.Parse(targetString);

                    if (string.IsNullOrEmpty(mapping.Parameters["precision"]))
                    {
                        return left.Equals(right); //完全精度匹配(几乎不可能实现)
                    }
                    else
                    {
                        int precision = int.Parse(mapping.Parameters["precision"]);
                        double delta = Math.Abs(left - right) * Math.Pow(10, precision); //通常两个数相差在delta范围内算相等
                        return delta < 1;
                    }
                }
                else
                    return false; // 左边对象有值,而右边对象没值
            }
            else if (srcValue is string)
            {
                return ((string)srcValue) == targetString;
            }
            else
            {
                return mapping.Parameters["sourceDefaultValue"] == targetString; //源对象为null或其他情形
            }
        }
Ejemplo n.º 10
0
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            var srcValue     = srcValues[mapping.SourceProperty] ?? Common.EmptyString;
            var targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (typeof(DateTime).IsAssignableFrom(srcValue.GetType()))
            {
                if (string.IsNullOrEmpty(targetString) == false)
                {
                    DateTime left  = (DateTime)srcValue;
                    DateTime right = DateTime.Parse(targetString);

                    return(left.Equals(right)); //完全精度匹配(几乎不可能实现)
                }
                else
                {
                    return(false); // 左边对象有值,而右边对象没值
                }
            }
            else if (srcValue is string)
            {
                return(((string)srcValue) == targetString);
            }
            else
            {
                return(mapping.Parameters["sourceDefaultValue"] == targetString); //源对象为null或其他情形
            }
        }
 public FileExplorer(NameObjectCollection fileFunctionMap)
 {
     m_fileFunctionMap = fileFunctionMap;
     _quit = false;
     m_DNV = Settings.Instance.DNV;
     m_indexer = new Indexer(Properties.Settings.Instance.TempIndexPath, IndexMode.CREATE);
 }
        private NameObjectCollection PrepareWxeFunctionParameters(int[] listIndices, IBusinessObject[] businessObjects)
        {
            NameObjectCollection parameters = new NameObjectCollection();

            parameters["indices"] = listIndices;
            parameters["objects"] = businessObjects;
            if (businessObjects.Length > 0 && businessObjects[0] is IBusinessObjectWithIdentity)
            {
                string[] ids = new string[businessObjects.Length];
                for (int i = 0; i < businessObjects.Length; i++)
                {
                    ids[i] = ((IBusinessObjectWithIdentity)businessObjects[i]).UniqueIdentifier;
                }
                parameters["ids"] = ids;
            }
            if (OwnerControl != null)
            {
                if (OwnerControl.DataSource != null && OwnerControl.Value != null)
                {
                    parameters["parent"] = OwnerControl.DataSource.BusinessObject;
                }
                if (OwnerControl.Property != null)
                {
                    parameters["parentproperty"] = OwnerControl.Property;
                }
            }

            return(parameters);
        }
Ejemplo n.º 13
0
        /// <summary> Converts a <see cref="WxeVariableReference"/>'s value to its string representation. </summary>
        /// <param name="varRef">
        ///   The <see cref="WxeVariableReference"/> to be converted. The referenced value must be of assignable to the
        ///   <see cref="WxeParameterDeclaration"/>'s <see cref="Type"/>. Must not be <see langword="null"/>.
        /// </param>
        /// <param name="callerVariables">
        ///   The optional list of caller variables. Used to dereference a <see cref="WxeVariableReference"/>.
        /// </param>
        /// <returns>
        ///   A <see cref="string"/> or <see langword="null"/> if the conversion is not possible but the parameter is not
        ///   required.
        /// </returns>
        /// <exception cref="WxeException"> Thrown if the value referenced by the <paramref name="varRef"/> could not be converted. </exception>
        protected string ConvertVarRefToString(WxeVariableReference varRef, NameObjectCollection callerVariables)
        {
            ArgumentUtility.CheckNotNull("varRef", varRef);

            if (callerVariables == null)
            {
                if (_parameter.Required)
                {
                    throw new WxeException(string.Format(
                                               "Required IN parameter '{0}' is a Variable Reference but no caller variables have been provided.",
                                               _parameter.Name));
                }
                return(null);
            }

            object value = callerVariables[_parameter.Name];

            if (value is WxeVariableReference)
            {
                if (_parameter.Required)
                {
                    throw new WxeException(string.Format(
                                               "Required IN parameter '{0}' is a Variable Reference but no caller variables have been provided.",
                                               _parameter.Name));
                }
                return(null);
            }

            return(ConvertObjectToString(value));
        }
 /// <summary> Copy a single caller variable to a callee parameter. </summary>
 public void CopyToCallee(string actualParameterName, NameObjectCollection callerVariables, NameObjectCollection calleeVariables)
 {
     if (_direction != WxeParameterDirection.Out)
     {
         CopyParameter(actualParameterName, callerVariables, _name, calleeVariables, _required);
     }
 }
Ejemplo n.º 15
0
        /// <summary> Executes the <see cref="WxeFunction"/> defined by the <see cref="WxeFunctionCommandInfo"/>. </summary>
        /// <param name="wxePage">
        ///   The <see cref="IWxePage"/> where this command is rendered on. Must not be <see langword="null"/>.
        /// </param>
        /// <param name="additionalWxeParameters">
        ///   The parameters passed to the <see cref="WxeFunction"/> in addition to the executing function's variables.
        ///   Use <see langword="null"/> or an empty collection if all parameters are supplied by the
        ///   <see cref="WxeFunctionCommandInfo.Parameters"/> string and the function stack.
        /// </param>
        /// <exception cref="InvalidOperationException">
        ///   <para>
        ///     Thrown if called while the <see cref="Type"/> is not set to <see cref="CommandType.WxeFunction"/>.
        ///   </para><para>
        ///     Thrown if neither the <see cref="WxeFunctionCommandInfo.MappingID"/> nor the
        ///     <see cref="WxeFunctionCommandInfo.TypeName"/> are set.
        ///   </para><para>
        ///     Thrown if the <see cref="WxeFunctionCommandInfo.MappingID"/> and <see cref="WxeFunctionCommandInfo.TypeName"/>
        ///     specify different functions.
        ///   </para>
        /// </exception>
        public virtual void ExecuteWxeFunction(IWxePage wxePage, NameObjectCollection additionalWxeParameters)
        {
            ArgumentUtility.CheckNotNull("wxePage", wxePage);

            if (Type != CommandType.WxeFunction)
            {
                throw new InvalidOperationException("Call to ExecuteWxeFunction not allowed unless Type is set to CommandType.WxeFunction.");
            }

            if (!wxePage.IsReturningPostBack)
            {
                string      target    = WxeFunctionCommand.Target;
                bool        hasTarget = !string.IsNullOrEmpty(target);
                WxeFunction function  = WxeFunctionCommand.InitializeFunction(additionalWxeParameters);

                IWxeCallArguments callArguments;
                if (hasTarget)
                {
                    callArguments = new WxeCallArguments((Control)OwnerControl, new WxeCallOptionsExternal(target, null, false));
                }
                else
                {
                    callArguments = WxeCallArguments.Default;
                }

                try
                {
                    wxePage.ExecuteFunction(function, callArguments);
                }
                catch (WxeCallExternalException)
                {
                }
            }
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method sets up the AST node and its children in the AST.</summary>
 ///
 /// <param name="context">The parsing context.</param>
 /// <param name="treeNode">The corresponding node in the parse tree.</param>
 ///--------------------------------------------------------------------------------
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     try
     {
         base.Init(context, treeNode);
         Parameters      = new List <TemplateParameterNode>();
         ParameterValues = new NameObjectCollection();
         foreach (ParseTreeNode node in treeNode.ChildNodes)
         {
             if (node.AstNode is IdentifierNode)
             {
                 TemplateName = node.FindTokenAndGetText();
             }
             else if (node.AstNode is TemplateParameterListNode)
             {
                 foreach (ParseTreeNode childNode in node.ChildNodes)
                 {
                     if (childNode.AstNode is TemplateParameterNode)
                     {
                         Parameters.Add(childNode.AstNode as TemplateParameterNode);
                         ChildNodes.Add(childNode.AstNode as TemplateParameterNode);
                     }
                 }
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         ThrowASTException(ex, true);
     }
 }
Ejemplo n.º 17
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (Entity entity in EntityList)
     {
         entity.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 18
0
 public NameObjectCollection(NameObjectCollection source)
     : base(source.Count)
 {
     for (int i = 0; i < source.Count; i++)
     {
         this.BaseAdd(source.BaseGetKey(i), source.BaseGet(i));
     }
 }
Ejemplo n.º 19
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (StepTransition stepTransition in ToStepTransitionList)
     {
         stepTransition.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 20
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (ViewProperty viewProperty in ViewPropertyList)
     {
         viewProperty.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 21
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (PropertyRelationship propertyRelationship in PropertyRelationshipList)
     {
         propertyRelationship.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 22
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (PropertyInstance propertyInstance in PropertyInstanceList)
     {
         propertyInstance.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 23
0
        private string BuildUri(NameObjectCollection nameValues)
        {
            string parameters = string.Join("&", nameValues.Select(n => n.Key + "=" + n.Value.ToString()).ToArray());

            var uri = String.Format("http://{0}/cgi-bin/camera_quality.cgi?view_sw=0&{1}", this.IPAddress, parameters);

            return(uri);
        }
        public void NameObjectCollection_Add_Default_AddsTheEntry()
        {
            NameObjectCollection<int> collection = new NameObjectCollection<int>(StringComparer.Ordinal);

            collection.Add("test", 42);

            Assert.That(collection, Has.Count.EqualTo(1));
        }
Ejemplo n.º 25
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (Value value in ValueList)
     {
         value.AddItemToUsedTags(usedTags);
     }
 }
 /// <summary> Set the parameter variables[parameterName] to the specified value. </summary>
 private void SetParameter(string parameterName, object value, NameObjectCollection variables)
 {
     if (value != null && _type != null && !_type.IsAssignableFrom(value.GetType()))
     {
         throw new ApplicationException("Parameter '" + parameterName + "' has unexpected type " + value.GetType().FullName + " (" + _type.FullName + " was expected).");
     }
     variables[parameterName] = value;
 }
Ejemplo n.º 27
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (DiagramEntity diagramEntity in DiagramEntityList)
     {
         diagramEntity.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 28
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds this item's tags into a named tag dictionary.</summary>
 ///
 /// <param name="usedTags">Input named tag dictionary.</param>
 ///--------------------------------------------------------------------------------
 public virtual void AddItemToUsedTags(NameObjectCollection usedTags)
 {
     AddTagsToUsedTags(usedTags);
     foreach (State state in StateList)
     {
         state.AddItemToUsedTags(usedTags);
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        ///     Convert a KeyValuePair into a NameObjectCollection object.
        /// </summary>
        /// <typeparam name="T">The type of value contained within the KeyValuePair.</typeparam>
        /// <param name="pairs">The KeyValuePair instances to convert.</param>
        /// <returns>A NameObjectCollection containing the keys and values from <paramref name="pairs" />.</returns>
        public static NameObjectCollectionBase ToNameObjectCollection <T>(
            this IEnumerable <KeyValuePair <string, T> > pairs)
        {
            var collection = new NameObjectCollection <T>();

            collection.AddRange(pairs);
            return(collection);
        }
Ejemplo n.º 30
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds relationships for an entity to the view model.</summary>
        ///
        /// <param name="entity">The entity to add.</param>
        ///--------------------------------------------------------------------------------
        public void AddRelationships(DiagramEntityViewModel diagramEntity)
        {
            NameObjectCollection relationshipsAdded = new NameObjectCollection();

            // add relationships this entity is the source of
            foreach (Relationship relationship in diagramEntity.EntityViewModel.Entity.RelationshipList)
            {
                bool isDeletedRelationship = false;
                foreach (DiagramRelationshipViewModel diagramRelationship in ItemsToDelete.OfType <DiagramRelationshipViewModel>())
                {
                    if (diagramRelationship.RelationshipViewModel.Relationship.RelationshipID == relationship.RelationshipID)
                    {
                        isDeletedRelationship = true;
                        break;
                    }
                }
                if (isDeletedRelationship == false && relationshipsAdded[relationship.RelationshipID.ToString()] == null)
                {
                    foreach (DiagramEntityViewModel loopEntity in DiagramEntities)
                    {
                        if (relationship.ReferencedEntityID == loopEntity.EntityViewModel.Entity.EntityID)
                        {
                            RelationshipViewModel relationshipViewModel = new RelationshipViewModel(relationship, Solution);
                            AddRelationship(diagramEntity, loopEntity, relationshipViewModel);
                            relationshipsAdded[relationship.RelationshipID.ToString()] = true;
                        }
                    }
                }
            }

            // add relationships this entity is the sink of
            foreach (DiagramEntityViewModel loopEntity in DiagramEntities)
            {
                foreach (Relationship relationship in loopEntity.EntityViewModel.Entity.RelationshipList)
                {
                    if (relationship.ReferencedEntityID == diagramEntity.EntityViewModel.Entity.EntityID)
                    {
                        bool isDeletedRelationship = false;
                        foreach (DiagramRelationshipViewModel diagramRelationship in ItemsToDelete.OfType <DiagramRelationshipViewModel>())
                        {
                            if (diagramRelationship.RelationshipViewModel.Relationship.RelationshipID == relationship.RelationshipID)
                            {
                                isDeletedRelationship = true;
                                break;
                            }
                        }
                        if (isDeletedRelationship == false && relationshipsAdded[relationship.RelationshipID.ToString()] == null)
                        {
                            RelationshipViewModel relationshipViewModel = new RelationshipViewModel(relationship, Solution);
                            AddRelationship(loopEntity, diagramEntity, relationshipViewModel);
                            relationshipsAdded[relationship.RelationshipID.ToString()] = true;
                        }
                    }
                }
            }

            Refresh(false);
        }
        /// <summary> Copy a value to a callee parameter. </summary>
        public void CopyToCallee(object parameterValue, NameObjectCollection calleeVariables)
        {
            if (_direction == WxeParameterDirection.Out)
            {
                throw new ApplicationException("Constant provided for output parameter.");
            }

            SetParameter(_name, parameterValue, calleeVariables);
        }
Ejemplo n.º 32
0
        private void PopulateDigitalGains()
        {
            var digitalGains = new NameObjectCollection();

            digitalGains.Add(new NameObjectPair("关", 0));
            digitalGains.Add(new NameObjectPair("开", 1));

            this.PopulateComboBox(digitalGains, this.digitalGain);
        }
Ejemplo n.º 33
0
            public virtual WxeFunction InitializeFunction(NameObjectCollection additionalWxeParameters)
            {
                Type        functionType = ResolveFunctionType();
                WxeFunction function     = (WxeFunction)Activator.CreateInstance(functionType);

                function.VariablesContainer.InitializeParameters(_parameters, additionalWxeParameters);

                return(function);
            }
 /// <summary>
 ///   Executes the <see cref="WxeFunction"/> defined by the <see cref="WxeFunctionCommand"/>.
 /// </summary>
 /// <param name="wxePage"> The <see cref="IWxePage"/> where this command is rendered on. </param>
 /// <param name="listIndices">
 ///   The array of indices for the <see cref="IBusinessObject"/> instances on which the rendered
 ///   command is applied on.
 /// </param>
 /// <param name="businessObjects">
 ///   The array of <see cref="IBusinessObject"/> instances on which the rendered command is applied on.
 /// </param>
 public void ExecuteWxeFunction(IWxePage wxePage, int[] listIndices, IBusinessObject[] businessObjects)
 {
     ArgumentUtility.CheckNotNull("wxePage", wxePage);
     if (!wxePage.IsReturningPostBack)
     {
         NameObjectCollection parameters = PrepareWxeFunctionParameters(listIndices, businessObjects);
         ExecuteWxeFunction(wxePage, parameters);
     }
 }
        /// <summary> Copy fromVariables[fromName] to toVariables[toName]. </summary>
        private void CopyParameter(string fromName, NameObjectCollection fromVariables, string toName, NameObjectCollection toVariables, bool required)
        {
            object value = fromVariables[fromName];

            if (value == null && required)
            {
                throw new ApplicationException("Parameter '" + fromName + "' is missing.");
            }
            SetParameter(toName, value, toVariables);
        }
Ejemplo n.º 36
0
 public virtual void SetPath(NameObjectCollection path)
 {
     while (this.Controls.Count > 1)
     {
         this.Retract();
     }
     foreach (var comp in path)
     {
         this.Expand(comp.Key, comp.Value);
     }
 }
        public void SetValue(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            var srcValue = srcValues[mapping.SourceProperty] ?? Common.EmptyString;

            if (typeof(int).IsAssignableFrom(srcValue.GetType()))
            {
                targetObj.Properties[mapping.TargetProperty].StringValue = ((int)srcValue).ToString();
            }
            else if (srcValue is string)
            {
                targetObj.Properties[mapping.TargetProperty].StringValue = (string)srcValue;
            }
            else
            {
                //其他情况如null,DbNull等,以及不知如何转换的
                targetObj.Properties[mapping.TargetProperty].StringValue = string.Empty ;
            }
        }
Ejemplo n.º 38
0
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            string enumType = mapping.Parameters["enumType"];
            if (string.IsNullOrEmpty(enumType))
                throw new System.Configuration.ConfigurationErrorsException("配置EnumPropertyComparer时,必须指定enumType属性");

            var type = Type.GetType(enumType);
            if (type == null)
                throw new System.Configuration.ConfigurationErrorsException("未找到指定的枚举类型 " + enumType);

            object srcValue = srcValues[mapping.SourceProperty];

            string targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (string.IsNullOrEmpty(targetString) == false)
            {
                return srcValue.Equals(int.Parse(targetString));
            }
            else
                return false;
        }
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            var srcValue = srcValues[mapping.SourceProperty] ?? Common.EmptyString;
            var targetString = targetObj.Properties[mapping.TargetProperty].StringValue;

            if (typeof(bool).IsAssignableFrom(srcValue.GetType()))
            {
                if (string.IsNullOrEmpty(targetString) == false)
                {
                    return ((bool)srcValue).Equals(bool.Parse(targetString));
                }
                else
                    return false; // 左边对象有值,而右边对象没值
            }
            else if (srcValue is string)
            {
                return string.Equals((string)srcValue, (string)targetString, StringComparison.OrdinalIgnoreCase);
            }
            else
            {
                return mapping.Parameters["sourceDefaultValue"] == targetString; //源对象为null或其他情形
            }
        }
        private NameObjectCollection<int> GetTestCollection()
        {
            NameObjectCollection<int> collection = new NameObjectCollection<int>(StringComparer.Ordinal);
            collection.Add("0", 0);
            collection.Add("1", 1);
            collection.Add("test", 42);

            return collection;
        }
Ejemplo n.º 41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="header"></param>
        public ResultSet(string[] columns, NameObjectCollection header)
        {
            this.header = header;
            this.config = null;
            this.columns = new StringList();
            this.data = new ArrayListList();

            if (columns != null) {
                foreach (string col in columns)
                    this.columns.Add(col);
            }
        }
Ejemplo n.º 42
0
 public void Add(NameObjectCollection col)
 {
     foreach (string key in col.Keys)
         BaseSet(key, col[key]);
 }
Ejemplo n.º 43
0
        private static NameObjectCollection ParseCameraProperties(System.IO.Stream replyStream)
        {
            var nameValues = new NameObjectCollection();
            using (StreamReader rdr = new StreamReader(replyStream))
            {
                while (true)
                {
                    var line = rdr.ReadLine();

                    if (line == null)//end of stream
                    {
                        break;
                    }

                    if (ShouldSkip(line)) continue;

                    try
                    {
                        var keyValue = ParseSemicommaSplittedLine(line);
                        if (!nameValues.ContainsKey(keyValue.Key))
                        {
                            nameValues.Add(keyValue.Key, keyValue.Value);
                        }
                    }
                    catch (System.ArgumentException){}

                }

                return nameValues;

            }
        }
Ejemplo n.º 44
0
 void Tree_SelectionChanged(object sender, EventArgs e)
 {
     TreePath tpath = Tree.GetPath(Tree.SelectedNode);
     NameObjectCollection path = new NameObjectCollection(tpath.FullPath.Length);
     foreach (var obj in tpath.FullPath)
     {
         Entry ent = (Entry)obj;
         path.Add(ent != null ? ent.InternalName : null, ent);
     }
     pathDisplay.SetPath(path);
 }
Ejemplo n.º 45
0
        public void SetAGCMode(bool AgcEnable, bool digitalGainEnable)
        {
            int agcModeValue = AgcEnable ? 1 : 0;
            int digitalGainValue = digitalGainEnable ? 1 : 0;


            var nameValues = new NameObjectCollection();
            nameValues.Add(_AgcMode, agcModeValue);
            nameValues.Add(_DigitalGain, digitalGainValue);

            string uri = BuildUri(nameValues);

            SetCameraProperty(uri);
        }
Ejemplo n.º 46
0
 public NameObjectCollection(NameObjectCollection col)
 {
     foreach (string key in col.Keys)
         BaseAdd(key, col[key]);
 }
Ejemplo n.º 47
0
        public void SetShutter(ShutterMode mode, int speedLevel)
        {
            int modeValue = 0;
            string speedPropertyName = null;
            switch (mode)
            {
                case ShutterMode.Off:
                    modeValue = 0;
                    speedPropertyName = "dummy";
                    break;
                case ShutterMode.Short:
                    modeValue = 1;
                    speedPropertyName = _ShutterShortSpeedLevel;
                    break;
                case ShutterMode.Long:
                    modeValue = 2;
                    speedPropertyName = _ShutterLongSpeedLevel;
                    break;
                default:
                    throw new InvalidEnumArgumentException("mode");
                    break;
            }

            var nameValues = new NameObjectCollection();
            nameValues.Add(_ShutterMode, modeValue);
            nameValues.Add(speedPropertyName, speedLevel);

            string uri = BuildUri(nameValues);

            SetCameraProperty(uri);
        }
Ejemplo n.º 48
0
        public void UpdateProperty()
        {
            EnsureConnected();

            var nameValues = new NameObjectCollection();
            nameValues.Add("status", 1);

            var uri = this.BuildUri(nameValues);
            var reply = this.GetHttpRequest(uri, this.cookies, true);

            try
            {
                var properties = ParseCameraProperties(reply.GetResponseStream());
                this.properties = properties;
            }
            finally
            {
                reply.Close();
            }

            
        }
        public void Should_only_clear_all_flash_related_session_data()
        {
            _httpContext.Stub(x => x.Session).Return(_sessionState);
            var nameObjectCollection = new NameObjectCollection
            {
                {RequestDataProvider.REQUESTDATA_PREFIX_KEY + "Property1", _flashViewModelForTesting.Property1},
                {"OtherData", new object()},
                {RequestDataProvider.REQUESTDATA_PREFIX_KEY + "Property2", _flashViewModelForTesting.Property3}
            };
            _sessionState.Stub(x => x.Keys).Return(nameObjectCollection.Keys);

            new RequestDataProvider(_httpContext).Clear();

            _sessionState.AssertWasCalled(x => x.Remove(RequestDataProvider.REQUESTDATA_PREFIX_KEY + "Property1"));
            _sessionState.AssertWasNotCalled(x => x.Remove("OtherData"));
            _sessionState.AssertWasCalled(x => x.Remove(RequestDataProvider.REQUESTDATA_PREFIX_KEY + "Property2"));
        }
Ejemplo n.º 50
0
        public void SetIris(IrisMode mode, int level)
        {
            int irisModeValue = 0;
            string propertyName = null;
            switch (mode)
            {
                case IrisMode.Auto:
                    irisModeValue = 0;
                    propertyName = _IrisAutoLevel;
                    break;
                case IrisMode.Manual:
                    irisModeValue = 1;
                    propertyName = _IrisManualLevel;
                    break;
                default:
                    throw new InvalidEnumArgumentException("mode is invalid");
                    break;
            }


            var nameValues = new NameObjectCollection();
            nameValues.Add(_IrisMode, irisModeValue);
            nameValues.Add(propertyName, level);

            var uri = BuildUri(nameValues);

            SetCameraProperty(uri);

        }
Ejemplo n.º 51
0
        private string BuildUri(NameObjectCollection nameValues)
        {
            string parameters = string.Join("&", nameValues.Select(n => n.Key + "=" + n.Value.ToString()).ToArray());

            var uri = String.Format("http://{0}/cgi-bin/camera_quality.cgi?{1}", this.IPAddress, parameters);

            return uri;

        }
Ejemplo n.º 52
0
 public NameObjectCollection(int capacity, NameObjectCollection col)
     : base(capacity)
 {
     Add(col);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FakeHttpApplicationState"/> class.
 /// </summary>
 public FakeHttpApplicationState()
 {
     this.items = new NameObjectCollection<object>(StringComparer.InvariantCultureIgnoreCase);
     this.staticObjects = new HttpStaticObjectsCollectionWrapper(new HttpStaticObjectsCollection());
 }
Ejemplo n.º 54
0
        private void PopulateDigitalGains()
        {
            var digitalGains = new NameObjectCollection();
            digitalGains.Add(new NameObjectPair("关", 0));
            digitalGains.Add(new NameObjectPair("开", 1));

            this.PopulateComboBox(digitalGains, this.digitalGain);
        }
 public DataCacheGetEnumerator(NameObjectCollection array)
 {
     domainArray = array;
 }
        /// <summary>
        /// Creates the Html element collection.
        /// </summary>
        /// <param name="htmlContent"> The HTML Content.</param>
        /// <param name="tagName"> The tag name.</param>
        /// <returns> A string value.</returns>
        public static NameObjectCollection CreateHtmlElement(string htmlContent, string tagName)
        {
            NameObjectCollection collection = new NameObjectCollection();

            string elementValue = string.Empty;

            StringBuilder rex = new StringBuilder();
            rex.Append(@"(?<header><(?i:");
            rex.Append(tagName);
            rex.Append(@")[^>]*?)(>|>(?<source>[\w|\t|\r|\W]*?)</(?i:");
            rex.Append(tagName);
            rex.Append(@")>)");

            Regex getElements = new Regex(rex.ToString(), RegexOptions.None);
            Regex getAttributes = (Regex)regex["GetAttributes"];

            // Get elements matches
            MatchCollection matches = getElements.Matches(htmlContent);

            // Example:
            // <input name='Username' ...
            // <input name='Username' ...
            // <input name='Password' ...

            // for each element
            for( int i=0;i<matches.Count;i++ )
            {
                string element = matches[i].Value;

                #region Search for element with name
                // get attributes
                MatchCollection attributes = getAttributes.Matches(element);

                int j=0;
                foreach (Match m in attributes)
                {
                    string name = m.Groups["name"].Value;
                    string value = m.Groups["value"].Value.ToLower(System.Globalization.CultureInfo.InvariantCulture);
                    name = name.ToLower(System.Globalization.CultureInfo.InvariantCulture);

                    // Create Item in collection
                    if ( name == "name" )
                    {
                        if ( collection[value] != null )
                        {
                            HtmlLightParserElement liteElement = (HtmlLightParserElement)collection[value];
                            if ( !liteElement.Contains(element) )
                            {
                                liteElement.Add(element);
                            }
                        }
                        else
                        {
                            collection.Add(value, new HtmlLightParserElement(element));
                        }
                    }
                    if ( name == "id" )
                    {
                        if ( collection[value] != null )
                        {
                            HtmlLightParserElement liteElement = (HtmlLightParserElement)collection[value];
                            if ( !liteElement.Contains(element) )
                            {
                                liteElement.Add(element);
                            }
                        }
                        else
                        {
                            collection.Add(value, new HtmlLightParserElement(element));
                        }
                    }
                    if ( collection[tagName] != null )
                    {
                        HtmlLightParserElement liteElement = (HtmlLightParserElement)collection[tagName];
                        if ( !liteElement.Contains(element) )
                        {
                            liteElement.Add(element);
                        }
                    }
                    else
                    {
                        collection.Add(tagName, new HtmlLightParserElement(element));
                    }

                    j++;
                }
                #endregion
            }

            return collection;
        }
Ejemplo n.º 57
0
        private void PopulateShutterLevels()
        {
            var shutterLevels = new NameObjectCollection();

            shutterLevels.Add(new NameObjectPair("25", 0));
            shutterLevels.Add(new NameObjectPair("50", 1));
            shutterLevels.Add(new NameObjectPair("120", 2));
            shutterLevels.Add(new NameObjectPair("250", 3));
            shutterLevels.Add(new NameObjectPair("500", 4));
            shutterLevels.Add(new NameObjectPair("1000", 5));
            shutterLevels.Add(new NameObjectPair("2000", 6));
            shutterLevels.Add(new NameObjectPair("4000", 7));
            shutterLevels.Add(new NameObjectPair("10000", 8));

            PopulateComboBox(shutterLevels, this.shutterLevel);
            this.shutterLevel.SelectedIndex = 0;
        }