Esempio n. 1
0
 public override bool ContainsKey(string key)
 {
     if (@base.ContainsKey(key))
     {
         return(true);
     }
     return(parent != null && parent.ContainsKey(key));
 }
Esempio n. 2
0
 private void dialog_OkEvent(object sender, System.Collections.Generic.IDictionary <string, string> dictionary)
 {
     showLoadingLogin();
     if (dictionary.ContainsKey("token_type") && dictionary.ContainsKey("access_token"))
     {
         presenter.Authorized(dictionary["token_type"] + " " + dictionary["access_token"]);
     }
     else
     {
         ShowErrorLogin();
     }
 }
Esempio n. 3
0
        public virtual void RemoveCallback(Net.Vpc.Upa.Callback callback)
        {
            Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback        dcallback = (Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback)callback;
            System.Collections.Generic.IDictionary <string, object> conf      = dcallback.GetConfiguration();
            //        if (conf == null) {
            //            conf = new HashMap<String, Object>();
            //        }
            bool   fireBefore         = true;
            bool   fireAfter          = true;
            bool   trackSystemObjects = true;
            string nameFilter         = null;

            if (conf != null)
            {
                if (conf.ContainsKey("before"))
                {
                    fireBefore = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "before")).Value;
                }
                if (conf.ContainsKey("after"))
                {
                    fireBefore = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "after")).Value;
                }
                if (conf.ContainsKey("trackSystemObjects"))
                {
                    trackSystemObjects = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "trackSystemObjects")).Value;
                }
                nameFilter = (string)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "nameFilter");
            }
            if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(nameFilter))
            {
                nameFilter = null;
            }
            Net.Vpc.Upa.Impl.Util.CallbackInvokerKey k = new Net.Vpc.Upa.Impl.Util.CallbackInvokerKey(callback.GetCallbackType(), callback.GetObjectType(), nameFilter, trackSystemObjects);
            System.Collections.Generic.IList <Net.Vpc.Upa.Callback> ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(before, k);
            if (ss != null)
            {
                ss.Remove(callback);
            }
            ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(after, k);
            if (ss != null)
            {
                ss.Remove(callback);
            }
            if (callback is Net.Vpc.Upa.PreparedCallback)
            {
                System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> sss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> >(preparedAfter, k);
                if (sss != null)
                {
                    sss.Remove((Net.Vpc.Upa.PreparedCallback)callback);
                }
            }
        }
Esempio n. 4
0
        // METHODS
        public TReturnValue MakeInstance(string key)
        {
            // checks
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (!factory.ContainsKey(key))
            {
                throw new InvalidOperationException($"No such key '{key}'");
            }

            // make instance
            return((TReturnValue)Activator.CreateInstance(factory[key]));
        }
        // METHODS
        /// <summary>
        /// Returns a new instance of a view model.
        /// </summary>
        /// <param name="key">
        /// A key by which view model was registered.
        /// </param>
        /// <returns>
        /// An instance of <see cref="ViewModelBase"/>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// Throws when <paramref name="key"/> is null.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Throws when key was not registered before.
        /// </exception>
        public ViewModelBase MakeInstance(string key)
        {
            // checks
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (!factory.ContainsKey(key))
            {
                throw new InvalidOperationException(string.Format(Core.Messages.Error.Admin.FACTORY_NO_SUCH_KEY_FORMAT, key));
            }

            // make instance
            return(Activator.CreateInstance(factory[key]) as ViewModelBase);
        }
Esempio n. 6
0
 public virtual System.Reflection.FieldInfo FindField(string name, Net.Vpc.Upa.Filters.ObjectFilter <System.Reflection.FieldInfo> filter)
 {
     System.Collections.Generic.IList <System.Reflection.FieldInfo> fieldsList = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IList <System.Reflection.FieldInfo> >(fields, name);
     if (fieldsList == null)
     {
         if (!fields.ContainsKey(name))
         {
             fieldsList = Net.Vpc.Upa.Impl.Util.PlatformUtils.FindFields(platformType, name);
             if ((fieldsList).Count > 0)
             {
                 fields[name] = fieldsList;
             }
             else
             {
                 fields[name] = null;
             }
         }
     }
     if (filter == null)
     {
         return(fieldsList[0]);
     }
     foreach (System.Reflection.FieldInfo field in fieldsList)
     {
         if (filter.Accept(field))
         {
             return(field);
         }
     }
     return(null);
 }
        /// <summary>
        /// Extension method for IDictionary.
        /// Adds a dictionary to an existing one.
        /// </summary>
        /// <param name="source">IDictionary-instance.</param>
        /// <param name="collection">Dictionary to add.</param>
        public static void CTAddRange <K, V>(this System.Collections.Generic.IDictionary <K, V> source, System.Collections.Generic.IDictionary <K, V> collection)
        {
            if (source == null)
            {
                throw new System.ArgumentNullException("source");
            }

            if (collection == null)
            {
                throw new System.ArgumentNullException("collection");
            }

            foreach (System.Collections.Generic.KeyValuePair <K, V> item in collection)
            {
                if (!source.ContainsKey(item.Key))
                {
                    source.Add(item.Key, item.Value);
                }
                else
                {
                    // handle duplicate key issue here
                    Debug.LogWarning("Duplicate key found: " + item.Key);
                }
            }
        }
Esempio n. 8
0
        protected bool IsInternalToDynamicProxy(Assembly asm)
        {
#if dotNet2
            internalsToDynProxyLock.AcquireReaderLock(-1);
            try
            {
                if (!internalsToDynProxy.ContainsKey(asm))
                {
                    internalsToDynProxyLock.UpgradeToWriterLock(-1);
                    InternalsVisibleToAttribute[] atts = (InternalsVisibleToAttribute[])asm.GetCustomAttributes(typeof(InternalsVisibleToAttribute), false);
                    bool found = false;
                    foreach (InternalsVisibleToAttribute internals in atts)
                    {
                        if (internals.AssemblyName.Contains(ModuleScope.ASSEMBLY_NAME))
                        {
                            found = true;
                            break;
                        }
                    }
                    internalsToDynProxy.Add(asm, found);
                }
                return(internalsToDynProxy[asm]);
            }
            finally
            {
                internalsToDynProxyLock.ReleaseLock();
            }
#else
            return(false);
#endif
        }
Esempio n. 9
0
 public static bool IsDebugEnabled(string logId)
 {
     if (!debugEnabled)
     {
         return(false);
     }
     if (logAll)
     {
         return(true);
     }
     if (logIds == null || logIds.Count == 0)
     {
         return(false);
     }
     return(logIds.ContainsKey(logId));
 }
        /// <summary>
        /// Extension method for IDictionary.
        /// Adds a dictionary to an existing one.
        /// </summary>
        /// <param name="dict">IDictionary-instance.</param>
        /// <param name="collection">Dictionary to add.</param>
        public static void CTAddRange <K, V>(this System.Collections.Generic.IDictionary <K, V> dict, System.Collections.Generic.IDictionary <K, V> collection)
        {
            if (dict == null)
            {
                throw new System.ArgumentNullException(nameof(dict));
            }

            if (collection == null)
            {
                throw new System.ArgumentNullException(nameof(collection));
            }

            foreach (System.Collections.Generic.KeyValuePair <K, V> item in collection)
            {
                if (!dict.ContainsKey(item.Key))
                {
                    dict.Add(item.Key, item.Value);
                }
                else
                {
                    // handle duplicate key issue here
                    Debug.LogWarning($"Duplicate key found: {item.Key}");
                }
            }
        }
Esempio n. 11
0
 public virtual bool IsReadingObjectInfoWithOid(NeoDatis.Odb.OID oid)
 {
     if (oid == null)
     {
         return(false);
     }
     return(readingObjectInfo.ContainsKey(oid));
 }
Esempio n. 12
0
 /// <summary>
 /// Get CurrentNodeEnum By Value
 /// </summary>
 public static CurrentNodeEnum GetFromValue(System.Int32 value)
 {
     //仅返回空的方法不是太好,在用的时候,枚举值可能就会设置一个枚举项中没有的,或者枚举值被删除.?
     if (!innerEnums.ContainsKey(value))
     {
         lock (lockobj)
         {
             if (!innerEnums.ContainsKey(value))
             {
                 CurrentNodeEnum newValue = new CurrentNodeEnum(value, "");
                 innerEnums.Add(value, newValue);
                 return(newValue);
             }
         }
     }
     return(innerEnums[value]);
 }
Esempio n. 13
0
 public virtual bool ContainsParameter(string name)
 {
     if (parameters != null)
     {
         return(parameters.ContainsKey(name));
     }
     return(false);
 }
        public void Add4Types_WithValidArgs_Adds4RegisteredTypes()
        {
            var container = new ServiceContainer();

            container.AddTransient <string>();
            container.AddTransient <Stream, MemoryStream>(factory => new MemoryStream());
            container.AddTransient <TextReader, StreamReader>();
            container.AddSingleton <decimal>();

            System.Collections.Generic.IDictionary <Type, Helpers.RegisteredType> settings = container.ExportSettings();

            // String
            Assert.IsTrue(settings.ContainsKey(typeof(string)));
            Helpers.RegisteredType stringRegisteredType = settings[typeof(string)];

            Assert.AreEqual(Lifetime.Transient, stringRegisteredType.Lifetime);
            Assert.IsFalse(stringRegisteredType.HasCustomConstructor);
            Assert.AreEqual(typeof(string), stringRegisteredType.ImplementationType);

            // Stream
            Assert.IsTrue(settings.ContainsKey(typeof(Stream)));
            Helpers.RegisteredType streamRegisteredType = settings[typeof(Stream)];

            Assert.AreEqual(Lifetime.Transient, streamRegisteredType.Lifetime);
            Assert.IsTrue(streamRegisteredType.HasCustomConstructor);
            Assert.IsNull(streamRegisteredType.ImplementationType);
            Assert.IsNotNull(streamRegisteredType.CustomConstructor);

            // TextReader
            Assert.IsTrue(settings.ContainsKey(typeof(TextReader)));
            Helpers.RegisteredType textReaderRegisteredType = settings[typeof(TextReader)];

            Assert.AreEqual(Lifetime.Transient, textReaderRegisteredType.Lifetime);
            Assert.IsFalse(textReaderRegisteredType.HasCustomConstructor);
            Assert.AreEqual(typeof(StreamReader), textReaderRegisteredType.ImplementationType);

            // Decimal
            Assert.IsTrue(settings.ContainsKey(typeof(decimal)));
            Helpers.RegisteredType decimalRegisteredType = settings[typeof(decimal)];

            Assert.AreEqual(Lifetime.Singleton, decimalRegisteredType.Lifetime);
            Assert.IsFalse(decimalRegisteredType.HasCustomConstructor);
            Assert.AreEqual(typeof(decimal), decimalRegisteredType.ImplementationType);
        }
Esempio n. 15
0
        private void cmbVariant_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (this.cmbVariant.Text.Trim().Length > 0)
            {
                this.m_strVariant = this.cmbVariant.Text.Trim().Substring(0, 2).ToString();

                if (m_strVariant.Trim().Length > 0)
                {
                    this.cmbFvsSpCd.Items.Clear();
                    // cache convertToSpcd
                    int intMyConvertToSpcd = -1;
                    if (m_intConvertToSpCd > 0)
                    {
                        intMyConvertToSpcd = m_intConvertToSpCd;
                    }
                    this.m_dictFvsCommonName.Clear();
                    m_ado.m_strSQL = "SELECT  spcd,fvs_species,common_name,fvs_common_name " +
                                     "FROM " + m_strFvsTreeSpcTable + " " +
                                     "WHERE LEN(TRIM(fvs_species)) > 0 AND " +
                                     "LEN(TRIM(common_name)) > 0 AND " +
                                     "TRIM(fvs_variant) = '" + m_strVariant.Trim() + "' order by spcd;";

                    m_ado.SqlQueryReader(m_ado.m_OleDbConnection, m_ado.m_OleDbTransaction, m_ado.m_strSQL);
                    if (m_ado.m_OleDbDataReader.HasRows)
                    {
                        while (m_ado.m_OleDbDataReader.Read())
                        {
                            string strMySpCd = Convert.ToString(m_ado.m_OleDbDataReader["spcd"]);
                            this.cmbFvsSpCd.Items.Add(strMySpCd + " - " + Convert.ToString(m_ado.m_OleDbDataReader["common_name"]) + " - " + m_ado.m_OleDbDataReader["fvs_species"]);
                            if (!m_dictFvsCommonName.ContainsKey(strMySpCd))
                            {
                                m_dictFvsCommonName.Add(strMySpCd, Convert.ToString(m_ado.m_OleDbDataReader["fvs_common_name"]));
                            }
                        }

                        if (intMyConvertToSpcd > 0)
                        {
                            this.intConvertToSpCd = intMyConvertToSpcd;
                        }
                    }
                    m_ado.m_OleDbDataReader.Close();
                }
            }
        }
Esempio n. 16
0
 public static void AddAllIfNotContains(System.Collections.Generic.IDictionary <string, string> hashtable, System.Collections.Generic.ICollection <string> items)
 {
     foreach (string s in items)
     {
         if (hashtable.ContainsKey(s) == false)
         {
             hashtable.Add(s, s);
         }
     }
 }
Esempio n. 17
0
        internal static bool TryAdd <TKey, TValue>(this System.Collections.Generic.IDictionary <TKey, TValue> dictionary, TKey key, TValue value)
        {
            if (dictionary.ContainsKey(key))
            {
                return(false);
            }

            dictionary.Add(key, value);
            return(true);
        }
        private ApplicationStartupParameters(System.Collections.Generic.IDictionary <string, string> initParams)
        {
            if (initParams.ContainsKey(Constants.SilverlightInitParameters.TimeoutUrl))
            {
                TimeoutUrl = initParams[Constants.SilverlightInitParameters.TimeoutUrl];
            }

            if (initParams.ContainsKey(Constants.SilverlightInitParameters.Username))
            {
                Username = initParams[Constants.SilverlightInitParameters.Username];
            }

            if (initParams.ContainsKey(Constants.SilverlightInitParameters.Session))
            {
                SessionToken = initParams[Constants.SilverlightInitParameters.Session];
            }

            if (initParams.ContainsKey(Constants.SilverlightInitParameters.IsSessionShared))
            {
                IsSessionShared = initParams[Constants.SilverlightInitParameters.IsSessionShared] == "true";
            }

            LocalIPAddress = initParams.ContainsKey(Constants.SilverlightInitParameters.LocalIPAddress)
                ? initParams[Constants.SilverlightInitParameters.LocalIPAddress]
                : SR.Unknown;

            bool logPerformance;

            if (initParams.ContainsKey(Constants.SilverlightInitParameters.LogPerformance) &&
                bool.TryParse(initParams[Constants.SilverlightInitParameters.LogPerformance], out logPerformance))
            {
                LogPerformance = logPerformance;
            }
            else
            {
                LogPerformance = false;
            }

            Mode = ApplicationServiceMode.BasicHttp;
            if (initParams.ContainsKey(Constants.SilverlightInitParameters.Mode))
            {
                ApplicationServiceMode mode;
                if (Enum.TryParse(initParams[Constants.SilverlightInitParameters.Mode], out mode))
                {
                    Mode = mode;
                }
            }

            Language = initParams.ContainsKey(Constants.SilverlightInitParameters.Language)
                ? initParams[Constants.SilverlightInitParameters.Language]
                : Thread.CurrentThread.CurrentUICulture.Name;
        }
Esempio n. 19
0
        public virtual void AddCallback(Net.Vpc.Upa.Callback callback)
        {
            Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback        dcallback = (Net.Vpc.Upa.Impl.Config.Callback.DefaultCallback)callback;
            System.Collections.Generic.IDictionary <string, object> conf      = dcallback.GetConfiguration();
            //        if (conf == null) {
            //            conf = new HashMap<String, Object>();
            //        }
            bool   fireBefore         = callback.GetPhase() == Net.Vpc.Upa.EventPhase.BEFORE;
            string nameFilter         = null;
            bool   trackSystemObjects = true;

            if (conf != null && conf.ContainsKey("trackSystemObjects"))
            {
                trackSystemObjects = ((bool?)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "trackSystemObjects")).Value;
            }
            nameFilter = conf == null ? null : (string)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(conf, "nameFilter");
            if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(nameFilter))
            {
                nameFilter = null;
            }
            if (fireBefore)
            {
                Net.Vpc.Upa.Impl.Util.CallbackInvokerKey k = new Net.Vpc.Upa.Impl.Util.CallbackInvokerKey(callback.GetCallbackType(), callback.GetObjectType(), nameFilter, trackSystemObjects);
                System.Collections.Generic.IList <Net.Vpc.Upa.Callback> ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(this.before, k);
                if (ss == null)
                {
                    ss             = new System.Collections.Generic.List <Net.Vpc.Upa.Callback>();
                    this.before[k] = ss;
                }
                ss.Add(callback);
            }
            else
            {
                Net.Vpc.Upa.Impl.Util.CallbackInvokerKey k = new Net.Vpc.Upa.Impl.Util.CallbackInvokerKey(callback.GetCallbackType(), callback.GetObjectType(), nameFilter, trackSystemObjects);
                System.Collections.Generic.IList <Net.Vpc.Upa.Callback> ss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.Callback> >(this.after, k);
                if (ss == null)
                {
                    ss            = new System.Collections.Generic.List <Net.Vpc.Upa.Callback>();
                    this.after[k] = ss;
                }
                ss.Add(callback);
                if (callback is Net.Vpc.Upa.PreparedCallback)
                {
                    System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> sss = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.CallbackInvokerKey, System.Collections.Generic.IList <Net.Vpc.Upa.PreparedCallback> >(this.preparedAfter, k);
                    if (sss == null)
                    {
                        sss = new System.Collections.Generic.List <Net.Vpc.Upa.PreparedCallback>();
                        this.preparedAfter[k] = sss;
                    }
                    sss.Add((Net.Vpc.Upa.PreparedCallback)callback);
                }
            }
        }
Esempio n. 20
0
 /// <summary>Initializes the extension</summary>
 /// <param name="parameters">Initialization parameters: This class expects following parameters:
 /// <list type="table"><listheader><term>Parameter</term><description>Description</description>
 /// <item><term><c>PropertyName</c></term><description>Name of the property</description>. Required.</item>
 /// <item><term><c>TypeName</c></term><description>Name of type property <c>PropertyName</c> is property of. Required.</description></item>
 /// <item><term><c>NewName</c></term><description>Specified a new name of the property. Optional.</description></item>
 /// <item><term><c>OrAttributes</c></term><description>Represents attributes of the property as <see cref="MemberAttributes"/> value. These new attribuets are OR-ed with exising property attributes. Must be string representation of integer value in invariant culture. Optional.</description></item>
 /// <item><term><c>AndAttributes</c></term><description>Represents attributes of the property as <see cref="MemberAttributes"/> value. These new attributes are AND-ed with exising property attributes. Must be string representation of integer value in invariant culture. Optional.</description></item>
 /// <item><term><c>NewType</c></term><description>Change type of the property. Recognizes last character ? as <see cref="Nullable{T}"/>. Optional.</description></item>
 /// <item><term><c>FieldName</c></term><description>Only used with <c>NewType</c>. Name of backing field. Optional.</description></item>
 /// </listheader></list></param>
 /// <exception cref="KeyNotFoundException">A required parameter is not present in the <paramref name="parameters"/> dictionary.</exception>
 /// <exception cref="FormatException">Value for <c>AndAttributes</c> or <c>OrAttributes</c> cannot be parsed as integer in invariant culture.</exception>
 /// <exception cref="OverflowException">Value for <c>AndAttributes</c> or <c>OrAttributes</c> does not fall to range of <see cref="int"/>.</exception>
 public void Initialize(System.Collections.Generic.IDictionary <string, string> parameters)
 {
     propertyName = parameters["PropertyName"];
     typeName     = parameters["TypeName"];
     if (parameters.ContainsKey("NewName"))
     {
         newName = parameters["NewName"];
     }
     if (parameters.ContainsKey("OrAttributes"))
     {
         orAttributes = (MemberAttributes)int.Parse(parameters["OrAttributes"], System.Globalization.CultureInfo.InvariantCulture);
     }
     if (parameters.ContainsKey("AndAttributes"))
     {
         andAttributes = (MemberAttributes)int.Parse(parameters["AndAttributes"], System.Globalization.CultureInfo.InvariantCulture);
     }
     if (parameters.ContainsKey("NewType"))
     {
         newPropertyType = parameters["NewType"];
     }
     if (parameters.ContainsKey("NewRank"))
     {
         newArrayRank = int.Parse(parameters["NewRank"]);
     }
     if (parameters.ContainsKey("FieldName"))
     {
         backingField = parameters["FieldName"];                                     //Only to change type if property type changes
     }
 }
Esempio n. 21
0
        ///// <summary>
        ///// Log Trace ifnormation in the command line
        ///// </summary>
        ///// <param name="e"></param>
        //protected override void LogTrace(Microsoft.Web.Deployment.DeploymentTraceEventArgs args)
        //{
        //    string strMsg = args.Message;
        //    string strEventType =  "Trace";
        //    Framework.MessageImportance messageImportance = Microsoft.Build.Framework.MessageImportance.Low;

        //    if (args is Deployment.DeploymentFileSerializationEventArgs ||
        //        args is Deployment.DeploymentPackageSerializationEventArgs ||
        //        args is Deployment.DeploymentObjectChangedEventArgs ||
        //        args is Deployment.DeploymentSyncParameterEventArgs )
        //    {
        //        //promote those message only for those event
        //        strEventType = "Action";
        //        messageImportance = Microsoft.Build.Framework.MessageImportance.High;
        //    }

        //    if (!string.IsNullOrEmpty(strMsg))
        //    {
        //         switch (args.EventLevel)
        //         {
        //             case System.Diagnostics.TraceLevel.Off:
        //                 break;
        //             case System.Diagnostics.TraceLevel.Error:
        //                 _host.Log.LogError(strMsg);
        //                 break;
        //             case System.Diagnostics.TraceLevel.Warning:
        //                 _host.Log.LogWarning(strMsg);
        //                 break;
        //             default: // Is Warning is a Normal message
        //                 _host.Log.LogMessageFromText(strMsg, messageImportance);
        //                 break;

        //         }
        //    }
        //    // additionally we fire the Custom event for the detail information
        //    CustomBuildWithPropertiesEventArgs customBuildWithPropertiesEventArg = new CustomBuildWithPropertiesEventArgs(args.Message, null, TaskName);

        //    customBuildWithPropertiesEventArg.Add("TaskName", TaskName);
        //    customBuildWithPropertiesEventArg.Add("EventType", strEventType);
        //    AddAllPropertiesToCustomBuildWithPropertyEventArgs(customBuildWithPropertiesEventArg, args);
        //    _host.BuildEngine.LogCustomEvent(customBuildWithPropertiesEventArg);
        //}


        protected override void LogTrace(dynamic args, System.Collections.Generic.IDictionary <string, Microsoft.Build.Framework.MessageImportance> customTypeLoging)
        {
            string strMsg       = args.Message;
            string strEventType = "Trace";

            Framework.MessageImportance messageImportance = Microsoft.Build.Framework.MessageImportance.Low;

            System.Type argsT = args.GetType();
            if (MsDeploy.Utility.IsType(argsT, MSWebDeploymentAssembly.DynamicAssembly.GetType("Microsoft.Web.Deployment.DeploymentFileSerializationEventArgs")) ||
                MsDeploy.Utility.IsType(argsT, MSWebDeploymentAssembly.DynamicAssembly.GetType("Microsoft.Web.Deployment.DeploymentPackageSerializationEventArgs")) ||
                MsDeploy.Utility.IsType(argsT, MSWebDeploymentAssembly.DynamicAssembly.GetType("Microsoft.Web.Deployment.DeploymentObjectChangedEventArgs")) ||
                MsDeploy.Utility.IsType(argsT, MSWebDeploymentAssembly.DynamicAssembly.GetType("Microsoft.Web.Deployment.DeploymentSyncParameterEventArgs")))
            {
                //promote those message only for those event
                strEventType      = "Action";
                messageImportance = Microsoft.Build.Framework.MessageImportance.High;
            }
            else if (customTypeLoging != null && customTypeLoging.ContainsKey(argsT.Name))
            {
                strEventType      = "Trace";
                messageImportance = customTypeLoging[argsT.Name];
            }

            if (!string.IsNullOrEmpty(strMsg))
            {
                System.Diagnostics.TraceLevel level = (System.Diagnostics.TraceLevel)System.Enum.ToObject(typeof(System.Diagnostics.TraceLevel), args.EventLevel);
                switch (level)
                {
                case System.Diagnostics.TraceLevel.Off:
                    break;

                case System.Diagnostics.TraceLevel.Error:
                    _host.Log.LogError(strMsg);
                    break;

                case System.Diagnostics.TraceLevel.Warning:
                    _host.Log.LogWarning(strMsg);
                    break;

                default:     // Is Warning is a Normal message
                    _host.Log.LogMessageFromText(strMsg, messageImportance);
                    break;
                }
            }
            // additionally we fire the Custom event for the detail information
            CustomBuildWithPropertiesEventArgs customBuildWithPropertiesEventArg = new CustomBuildWithPropertiesEventArgs(args.Message, null, TaskName);

            customBuildWithPropertiesEventArg.Add("TaskName", TaskName);
            customBuildWithPropertiesEventArg.Add("EventType", strEventType);
            AddAllPropertiesToCustomBuildWithPropertyEventArgs(customBuildWithPropertiesEventArg, args);
            _host.BuildEngine.LogCustomEvent(customBuildWithPropertiesEventArg);
        }
Esempio n. 22
0
        public virtual bool ExistClass(string fullClassName)
        {
            // Check if it is a system class
            bool exist = rapidAccessForSystemClassesByName.ContainsKey(fullClassName);

            if (exist)
            {
                return(true);
            }
            // Check if it is user class
            exist = rapidAccessForUserClassesByName.ContainsKey(fullClassName);
            return(exist);
        }
Esempio n. 23
0
        private void VisitYamlScalarNode(string context, YamlDotNet.RepresentationModel.YamlScalarNode yamlValue)
        {
            //a node with a single 1-1 mapping
            EnterContext(context);
            string currentKey = _currentPath;

            if (_data.ContainsKey(currentKey))
            {
                throw new System.FormatException("Resources.FormatError_KeyIsDuplicated(currentKey)");
            }

            _data[currentKey] = yamlValue.Value;
            ExitContext();
        }
Esempio n. 24
0
 public virtual System.Reflection.MethodInfo GetMethod(System.Type type, string name, System.Type ret, params System.Type [] args)
 {
     Net.Vpc.Upa.Impl.Util.MethodSignature key    = new Net.Vpc.Upa.Impl.Util.MethodSignature(name, args);
     System.Reflection.MethodInfo          method = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Util.MethodSignature, System.Reflection.MethodInfo>(methods, key);
     if (method == null)
     {
         if (!methods.ContainsKey(key))
         {
             method       = GetMethod00(type, name, ret, args);
             methods[key] = method;
         }
     }
     return(method);
 }
Esempio n. 25
0
 private void setOutletTable(System.DateTime dateTime, System.Collections.Generic.Dictionary <int, OutletValueEntry> dictionary, int deviceId, int portNumbers, string mac, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, OutletMapping> > outletIdMapper)
 {
     try
     {
         if (dictionary == null || dictionary.Count < 1)
         {
             dictionary = new System.Collections.Generic.Dictionary <int, OutletValueEntry>();
             for (int i = 1; i <= portNumbers; i++)
             {
                 dictionary.Add(i, new OutletValueEntry(i));
             }
         }
         System.Collections.Generic.IEnumerator <int> enumerator = dictionary.Keys.GetEnumerator();
         while (enumerator.MoveNext())
         {
             int current = enumerator.Current;
             if (outletIdMapper.ContainsKey(mac) && outletIdMapper[mac].ContainsKey(current))
             {
                 OutletValueEntry outletValueEntry = dictionary[current];
                 OutletAutoValue  outletAutoValue  = new OutletAutoValue();
                 outletAutoValue.PortState = outletValueEntry.OutletStatus.ToString();
                 OutletMapping outletMapping = outletIdMapper[mac][current];
                 outletAutoValue.PortId           = outletMapping.OutletId;
                 outletAutoValue.Current          = this.ParseDeviceValue(outletValueEntry.Current);
                 outletAutoValue.Voltage          = this.ParseDeviceValue(outletValueEntry.Voltage);
                 outletAutoValue.Power            = this.ParseDeviceValue(outletValueEntry.Power);
                 outletAutoValue.PowerDissipation = this.ParseDeviceValue(outletValueEntry.PowerDissipation);
                 outletAutoValue.InsertTime       = this.parseSecondTime(dateTime);
                 this.presentValue.OutletTable.Rows.Add(new object[]
                 {
                     deviceId,
                     outletAutoValue.PortId,
                     outletMapping.OutletNumber,
                     outletMapping.OutletName,
                     outletAutoValue.Voltage,
                     outletAutoValue.Current,
                     outletAutoValue.Power,
                     outletAutoValue.PowerDissipation,
                     outletAutoValue.PortState,
                     outletAutoValue.InsertTime
                 });
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 26
0
 private void setBankTable(System.DateTime dateTime, System.Collections.Generic.Dictionary <int, BankValueEntry> dictionary, int deviceId, int bankNumbers, string mac, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, BankMapping> > bankIdMapper)
 {
     try
     {
         if (dictionary == null || dictionary.Count < 1)
         {
             dictionary = new System.Collections.Generic.Dictionary <int, BankValueEntry>();
             for (int i = 1; i <= bankNumbers; i++)
             {
                 dictionary.Add(i, new BankValueEntry(i));
             }
         }
         System.Collections.Generic.IEnumerator <int> enumerator = dictionary.Keys.GetEnumerator();
         while (enumerator.MoveNext())
         {
             int current = enumerator.Current;
             if (bankIdMapper.ContainsKey(mac) && bankIdMapper[mac].ContainsKey(current))
             {
                 BankValueEntry bankValueEntry = dictionary[current];
                 BankAutoValue  bankAutoValue  = new BankAutoValue();
                 bankAutoValue.BankState = bankValueEntry.BankStatus.ToString();
                 BankMapping bankMapping = bankIdMapper[mac][current];
                 bankAutoValue.BankId           = bankMapping.BankId;
                 bankAutoValue.Current          = this.ParseDeviceValue(bankValueEntry.Current);
                 bankAutoValue.Voltage          = this.ParseDeviceValue(bankValueEntry.Voltage);
                 bankAutoValue.Power            = this.ParseDeviceValue(bankValueEntry.Power);
                 bankAutoValue.PowerDissipation = this.ParseDeviceValue(bankValueEntry.PowerDissipation);
                 bankAutoValue.InsertTime       = this.parseSecondTime(dateTime);
                 this.presentValue.BankTable.Rows.Add(new object[]
                 {
                     deviceId,
                     bankAutoValue.BankId,
                     bankMapping.BankNumber,
                     bankMapping.BankName,
                     bankAutoValue.Voltage,
                     bankAutoValue.Current,
                     bankAutoValue.Power,
                     bankAutoValue.PowerDissipation,
                     bankAutoValue.BankState,
                     bankAutoValue.InsertTime
                 });
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 27
0
 public StructType(string name, System.Type clazz, string[] fieldNames, Net.Vpc.Upa.Types.DataType[] datatypes, bool nullable)  : base(name, clazz, datatypes.Length, 0, nullable)
 {
     if (fieldNames.Length != datatypes.Length)
     {
         throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException();
     }
     for (int i = 0; i < fieldNames.Length; i++)
     {
         if (elementsMap.ContainsKey(fieldNames[i]))
         {
             throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException();
         }
         elementsMap[fieldNames[i]] = datatypes[i];
         elementsList.Add(fieldNames[i]);
     }
 }
Esempio n. 28
0
 private System.Data.IDbCommand GetDbCommand(ISqlMapper sqlMapper, string statementName, StrObjectDict paramObject, StrObjectDict dictParam, System.Collections.Generic.IDictionary <string, System.Data.ParameterDirection> dictParmDirection, System.Data.CommandType cmdType)
 {
     System.Data.IDbCommand result;
     if (cmdType == System.Data.CommandType.Text)
     {
         result = this.GetDbCommand(sqlMapper, statementName, paramObject);
     }
     else
     {
         IStatement       statement       = sqlMapper.GetMappedStatement(statementName).Statement;
         IMappedStatement mappedStatement = sqlMapper.GetMappedStatement(statementName);
         ISqlMapSession   sqlMapSession   = new SqlMapSession(sqlMapper);
         if (sqlMapper.LocalSession != null)
         {
             sqlMapSession = sqlMapper.LocalSession;
         }
         else
         {
             sqlMapSession = sqlMapper.OpenConnection();
         }
         RequestScope requestScope = statement.Sql.GetRequestScope(mappedStatement, paramObject, sqlMapSession);
         mappedStatement.PreparedCommand.Create(requestScope, sqlMapSession, statement, paramObject);
         System.Data.IDbCommand dbCommand = sqlMapSession.CreateCommand(cmdType);
         dbCommand.CommandText = requestScope.IDbCommand.CommandText;
         if (cmdType != System.Data.CommandType.StoredProcedure || dictParam == null)
         {
             result = dbCommand;
         }
         else
         {
             foreach (System.Collections.Generic.KeyValuePair <string, object> current in dictParam)
             {
                 string text = current.Key.ToString();
                 System.Data.IDbDataParameter dbDataParameter = dbCommand.CreateParameter();
                 dbDataParameter.ParameterName = text;
                 dbDataParameter.Value         = current.Value;
                 if (dictParmDirection != null && dictParmDirection.ContainsKey(text))
                 {
                     dbDataParameter.Direction = dictParmDirection[text];
                 }
                 dbCommand.Parameters.Add(dbDataParameter);
             }
             result = dbCommand;
         }
     }
     return(result);
 }
Esempio n. 29
0
 private void setSensorTable(System.DateTime dateTime, System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary, int deviceId, int sensorNumbers, string mac, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, SensorMapping> > sensorIdMapper)
 {
     try
     {
         if (dictionary == null || dictionary.Count < 1)
         {
             dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
             for (int i = 1; i <= sensorNumbers; i++)
             {
                 dictionary.Add(i, new SensorValueEntry(i));
             }
         }
         System.Collections.Generic.IEnumerator <int> enumerator = dictionary.Keys.GetEnumerator();
         while (enumerator.MoveNext())
         {
             int current = enumerator.Current;
             if (sensorIdMapper.ContainsKey(mac) && sensorIdMapper[mac].ContainsKey(current))
             {
                 SensorValueEntry sensorValueEntry = dictionary[current];
                 SensorAutoValue  sensorAutoValue  = new SensorAutoValue();
                 SensorMapping    sensorMapping    = sensorIdMapper[mac][current];
                 int sensorLocation = sensorMapping.SensorLocation;
                 sensorAutoValue.DeviceId    = deviceId;
                 sensorAutoValue.Humidity    = this.ParseDeviceValue(sensorValueEntry.Humidity);
                 sensorAutoValue.InsertTime  = this.parseSecondTime(dateTime);
                 sensorAutoValue.Press       = this.ParseDeviceValue(sensorValueEntry.Pressure);
                 sensorAutoValue.Temperature = this.ParseDeviceValue(sensorValueEntry.Temperature);
                 sensorAutoValue.Type        = current;
                 this.presentValue.SensorTable.Rows.Add(new object[]
                 {
                     sensorAutoValue.DeviceId,
                     sensorAutoValue.Humidity,
                     sensorAutoValue.Temperature,
                     sensorAutoValue.Press,
                     sensorAutoValue.Type,
                     sensorLocation,
                     sensorAutoValue.InsertTime
                 });
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 30
0
 public override bool IsSet(string key)
 {
     if (nfo.ContainsProperty(key))
     {
         if (!ignoreUnspecified || !nfo.IsDefaultValue(userObject, key))
         {
             return(true);
         }
     }
     if (extra != null)
     {
         if (extra.ContainsKey(key))
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Creates a new command line argument parser.
        /// </summary>
        /// <param name="argumentSpecification"> The type of object to  parse. </param>
        /// <param name="reporter"> The destination for parse errors. </param>
        public Parser(Type argumentSpecification, ErrorReporter reporter)
        {
            this.reporter = reporter;
            this.arguments = new System.Collections.Generic.List<vcmd.Parser.Argument>();
            this.argumentMap = new System.Collections.Generic.Dictionary<string, vcmd.Parser.Argument> ();

            foreach (PropertyInfo prop in argumentSpecification.GetProperties())
            {
                MethodInfo propMethod = prop.GetGetMethod();
                if (!propMethod.IsStatic)
                {
                    ArgumentAttribute attribute = GetAttribute(prop);
                    if (attribute is DefaultArgumentAttribute)
                    {

                        this.defaultArgument = new Argument(attribute, prop, reporter);
                    }
                    else
                    {
                        Argument a = new Argument(attribute, prop, reporter);
                        this.arguments.Add(a);
                    }
                }
            }

            // add explicit names to map
            foreach (Argument argument in this.arguments)
            {

                this.argumentMap[argument.LongName] = argument;
                if (argument.ExplicitShortName)
                {
                    if (argument.ShortName != null && argument.ShortName.Length > 0)
                    {

                        this.argumentMap[argument.ShortName] = argument;
                    }
                    else
                    {
                        argument.ClearShortName();
                    }
                }
            }

            // add implicit names which don't collide to map
            foreach (Argument argument in this.arguments)
            {
                if (!argument.ExplicitShortName)
                {
                    if (argument.ShortName != null && argument.ShortName.Length > 0 && !argumentMap.ContainsKey(argument.ShortName))
                        this.argumentMap[argument.ShortName] = argument;
                    else
                        argument.ClearShortName();
                }
            }
        }