示例#1
0
        internal override SqlExpression VisitIn(SqlIn sin)
        {
            // Treat the IN as a series of binary comparison expressions (and coerce if necessary).
            // Check to see if any expressions need to change as a result of coercion, where we start
            // with "sin.Expression IN sin.Values" and coerced expressions are "test IN newValues".
            SqlExpression test             = sin.Expression;
            bool          requiresCoercion = false;
            var           newValues        = new Collections.Generic.List <SqlExpression>(sin.Values.Count);
            ProviderType  valueType        = null;

            for (int i = 0, n = sin.Values.Count; i < n; i++)
            {
                SqlExpression value = sin.Values[i];
                this.CoerceBinaryArgs(ref test, ref value);
                if (value != sin.Values[i])
                {
                    // Build up 'widest' type by repeatedly applying PredictType
                    valueType = null == valueType
                                                ? value.SqlType
                                                : this.typeProvider.PredictTypeForBinary(SqlNodeType.EQ, value.SqlType, valueType);
                    requiresCoercion = true;
                }
                newValues.Add(value);
            }
            if (test != sin.Expression)
            {
                requiresCoercion = true;
            }
            if (requiresCoercion)
            {
                ProviderType providerType = this.typeProvider.PredictTypeForBinary(SqlNodeType.EQ, test.SqlType, valueType);
                sin = new SqlIn(sin.ClrType, providerType, test, newValues, sin.SourceExpression);
            }
            return(sin);
        }
示例#2
0
        public override bool IsValid(object value)
        {
            if (value == null)
            {
                return(true);
            }
            int MaxContentLength = 1024 * 1024 * 3; //3 MB

            Collections.Generic.List <string> AllowedFileExtensions = new Collections.Generic.List <string> {
                ".jpg", ".gif", ".png"
            };

            var file = value as HttpPostedFileBase;

            if (file == null)
            {
                return(false);
            }

            else if (!AllowedFileExtensions.Contains(file.FileName.ToLower().Substring(file.FileName.LastIndexOf('.'))))
            {
                ErrorMessage = "Accepts jpg, .png, .gif up to 3MB.";// + string.Join(", ", AllowedFileExtensions);
                return(false);
            }
            else if (file.ContentLength > MaxContentLength)
            {
                ErrorMessage = "Your Photo is too large, maximum allowed size is : " + (MaxContentLength / 1024).ToString() + "MB";
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#3
0
        public void ListBoxItemAccessibleObject_DataBoundAccessibleName()
        {
            // Regression test for https://github.com/dotnet/winforms/issues/3706

            using var form = new Form
                  {
                      BindingContext = new BindingContext()
                  };

            using var control = new ListBox
                  {
                      Parent        = form,
                      DisplayMember = TestDataSources.PersonDisplayMember,
                      DataSource    = TestDataSources.GetPersons()
                  };

            ListBox.ListBoxAccessibleObject accessibleObject =
                Assert.IsType <ListBox.ListBoxAccessibleObject>(control.AccessibilityObject);

            Collections.Generic.List <Person> persons = TestDataSources.GetPersons();
            Assert.Equal(persons.Count, accessibleObject.GetChildCount());

            for (int i = 0; i < persons.Count; i++)
            {
                Person           person = persons[i];
                AccessibleObject itemAccessibleObject = accessibleObject.GetChild(i);

                Assert.IsType <ListBox.ListBoxItemAccessibleObject>(itemAccessibleObject);
                Assert.Equal(person.Name, itemAccessibleObject.Name);
            }

            Assert.False(control.IsHandleCreated);
        }
        public System.Collections.Generic.IEnumerable <MethodInfo> GetDeclaredMethods(string name)
        {
            System.Collections.Generic.List <MethodInfo> ls = new Collections.Generic.List <MethodInfo>();

            foreach (MethodInfo mi in this.DeclaredMethods)
            {
                if (string.Equals(mi.Name, name, StringComparison.Ordinal))
                {
                    ls.Add(mi);
                }
            }

            return(ls);
        }
示例#5
0
        /// <summary>
        /// 扫描文件列表
        /// </summary>
        /// <param name="path">文件路径,支持*匹配,多个路径用分号隔开,参数无效时直接反回空列表。</param>
        /// <param name="appPath">相对目录,默认为AppHelper.AppPath</param>
        /// <returns>返回匹配到的文件列表,文件路径为绝对路径</returns>
        public static System.Collections.Generic.List <string> Scan(string path, string appPath)
        {
            var list = new Collections.Generic.List <string>();

            if (string.IsNullOrEmpty(appPath))
            {
                appPath = AppHelper.AppPath;
            }
            if (string.IsNullOrEmpty(path))
            {
                return(list);
            }
            string[] paths = path.Split(';', ';');
            foreach (string p in paths)
            {
                if (string.IsNullOrEmpty(p))
                {
                    continue;
                }
                if (p.IndexOf('*') > -1)
                {
                    try {
                        list.AddRange(Directory.GetFiles(appPath, p, System.IO.SearchOption.TopDirectoryOnly));
                    } catch (System.IO.DirectoryNotFoundException) {
                    }
                }
                else
                {
                    string p10;
                    if (p.IndexOf(':') == -1 && !p.StartsWith("~/"))
                    {
                        p10 = System.IO.Path.Combine(appPath, p);
                    }
                    else
                    {
                        p10 = AppHelper.MapPath(p);
                    }
                    if (!System.IO.File.Exists(p10))
                    {
                        continue;
                    }
                    list.Add(p10);
                }
            }
            return(list);
        }
示例#6
0
 public byte[] Execute(byte[] buffer)
 {
     stream.Write(buffer, 0, buffer.Length);
     System.Collections.Generic.List <byte> lst = new Collections.Generic.List <byte>();
     if (stream.CanRead)
     {
         byte[] buff = new byte[1024];
         int    n    = 0;
         do
         {
             n = stream.Read(buff, 0, buff.Length);
             for (int i = 0; i < n; ++i)
             {
                 lst.Add(buff[i]);
             }
         }while (stream.DataAvailable);
     }
     return(lst.ToArray());
 }
示例#7
0
        /// <internalonly/>
        /// <devdoc>
        ///    <para>Gets a collection of standard values for the reference data type.</para>
        /// </devdoc>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            System.Collections.Generic.List <PropertyInfo> result = new Collections.Generic.List <PropertyInfo>();

            if (context.Instance is System.Windows.Forms.Control)
            {
                System.Windows.Forms.Control tmp = (System.Windows.Forms.Control)context.Instance;
                System.Windows.Forms.Form    frm = null;
                while (frm == null && tmp.Parent != null)
                {
                    if (tmp.Parent is System.Windows.Forms.Form)
                    {
                        frm = (System.Windows.Forms.Form)tmp.Parent;
                    }
                    else
                    {
                        tmp = tmp.Parent;
                    }
                }
                if (frm != null && frm is HKLabs.form3)
                {
                    HKLabs.form3 f3 = (HKLabs.form3)frm;
                    if (f3.AAA != null)
                    {
                        PropertyInfo[] p = f3.AAA.GetProperties();
                        foreach (PropertyInfo tmpP in p)
                        {
                            if (tmpP.CanWrite && tmpP.CanRead)
                            {
                                result.Add(tmpP);
                            }
                        }
                    }
                }
            }
            result.Sort((p1, p2) =>
            {
                return(String.Compare(p1.Name, p2.Name, false, CultureInfo.InvariantCulture));
            });
            return(new StandardValuesCollection(result.ToArray()));
        }
示例#8
0
 /// <internalonly/>
 /// <devdoc>
 ///    <para>获取所有下拉列表项</para>
 /// </devdoc>
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     System.Collections.Generic.List <Type> result = new Collections.Generic.List <Type>();
     Type[] t = Assembly.GetExecutingAssembly().GetTypes();
     if (t != null)
     {
         for (int i = 0; i < t.Length; i++)
         {
             //if (t[i].BaseType.Name == typeof(HKLabs.Tabel).Name ||
             //    t[i].Name == typeof(HKLabs.Tabel).Name)
             //{
             result.Add(t[i]);
             //}
         }
     }
     result.Sort((itemName1, itemName2) =>
     {
         return(string.Compare(itemName1.Name, itemName2.Name, false, CultureInfo.InvariantCulture));
     });
     return(new StandardValuesCollection(result.ToArray()));
 }
示例#9
0
文件: McgModule.cs 项目: tmds/corert
        internal bool TryGetImplementedInterfaces(int ccwTemplateIndex, out IEnumerable <RuntimeTypeHandle> interfaces)
        {
            if (ccwTemplateIndex >= 0)
            {
                interfaces = new Collections.Generic.List <RuntimeTypeHandle>();

                //
                // Walk the interface list
                //
                interfaces = new ArraySegment <RuntimeTypeHandle>(
                    m_supportedInterfaceList,
                    m_ccwTemplateData[ccwTemplateIndex].SupportedInterfaceListBeginIndex,
                    m_ccwTemplateData[ccwTemplateIndex].NumberOfSupportedInterface
                    );

                return(true);
            }

            interfaces = null;
            return(false);
        }
示例#10
0
        /// <summary>Canonicalizes the specified Access Control List.</summary>
        /// <param name="acl">The Access Control List.</param>
        public static void Canonicalize(this RawAcl acl)
        {
            if (acl == null)
            {
                throw new ArgumentNullException(nameof(acl));
            }

            // Extract aces to list
            var aces = new Collections.Generic.List <GenericAce>(acl.Cast <GenericAce>());

            // Sort aces based on canonical order
            aces.Sort((a, b) => Collections.Generic.Comparer <byte> .Default.Compare(GetComparisonValue(a), GetComparisonValue(b)));

            // Add sorted aces back to ACL
            while (acl.Count > 0)
            {
                acl.RemoveAce(0);
            }
            var aceIndex = 0;

            aces.ForEach(ace => acl.InsertAce(aceIndex++, ace));
        }
示例#11
0
        void IVSMSDeployHost.UpdateDeploymentBaseOptions(VSMSDeployObject srcVsMsDeployobject, VSMSDeployObject destVsMsDeployobject)
        {
            Collections.Generic.List <string> enableSkipDirectiveList  = MSDeployUtility.ConvertStringIntoList(EnableSkipDirective);
            Collections.Generic.List <string> disableSkipDirectiveList = MSDeployUtility.ConvertStringIntoList(DisableSkipDirective);

            MsDeploy.Utility.AddSkipDirectiveToBaseOptions(srcVsMsDeployobject.BaseOptions, null, enableSkipDirectiveList, disableSkipDirectiveList, Log);
            MsDeploy.Utility.AddSkipDirectiveToBaseOptions(destVsMsDeployobject.BaseOptions, null, enableSkipDirectiveList, disableSkipDirectiveList, Log);

            if (!string.IsNullOrEmpty(DeploymentTraceLevel))
            {
                Diagnostics.TraceLevel deploymentTraceEventLevel =
                    (Diagnostics.TraceLevel)System.Enum.Parse(typeof(Diagnostics.TraceLevel), DeploymentTraceLevel, true);
                srcVsMsDeployobject.BaseOptions.TraceLevel  = deploymentTraceEventLevel;
                destVsMsDeployobject.BaseOptions.TraceLevel = deploymentTraceEventLevel;
            }

            MsDeploy.Utility.AddSetParametersFilesVsMsDeployObject(srcVsMsDeployobject, ImportSetParametersItems);
            MsDeploy.Utility.AddSimpleSetParametersVsMsDeployObject(srcVsMsDeployobject, SimpleSetParameterItems, OptimisticParameterDefaultValue);
            MsDeploy.Utility.AddSetParametersVsMsDeployObject(srcVsMsDeployobject, SetParameterItems, OptimisticParameterDefaultValue);

            AddAdditionalProviderOptions(destVsMsDeployobject);
        }
示例#12
0
		internal override SqlExpression VisitIn(SqlIn sin)
		{
			// Treat the IN as a series of binary comparison expressions (and coerce if necessary).
			// Check to see if any expressions need to change as a result of coercion, where we start
			// with "sin.Expression IN sin.Values" and coerced expressions are "test IN newValues".
			SqlExpression test = sin.Expression;
			bool requiresCoercion = false;
			var newValues = new Collections.Generic.List<SqlExpression>(sin.Values.Count);
			ProviderType valueType = null;
			for(int i = 0, n = sin.Values.Count; i < n; i++)
			{
				SqlExpression value = sin.Values[i];
				this.CoerceBinaryArgs(ref test, ref value);
				if(value != sin.Values[i])
				{
					// Build up 'widest' type by repeatedly applying PredictType
					valueType = null == valueType
						? value.SqlType
						: this.typeProvider.PredictTypeForBinary(SqlNodeType.EQ, value.SqlType, valueType);
					requiresCoercion = true;
				}
				newValues.Add(value);
			}
			if(test != sin.Expression)
			{
				requiresCoercion = true;
			}
			if(requiresCoercion)
			{
				ProviderType providerType = this.typeProvider.PredictTypeForBinary(SqlNodeType.EQ, test.SqlType, valueType);
				sin = new SqlIn(sin.ClrType, providerType, test, newValues, sin.SourceExpression);
			}
			return sin;
		}