protected void btnOk_Click(object sender, EventArgs e)
    {
        ParamFacade facade = PageHelper.GetParamFacade(this.Page);
        ParamInfo param = facade.GetParam("AdministratorPassword");
        string oldPassword = EncryptTool.MD5(txtOldPassword.Text);
        string newPassword = EncryptTool.MD5(txtNewPassword.Text);
        string confirmPassword = EncryptTool.MD5(txtConfirmPassword.Text);
        if (newPassword != confirmPassword)
        {
            lblMessage.Text = "两次输入的密码不相同。";
            return;
        }
        if (param == null || string.IsNullOrEmpty(param.Value) || param.Value == oldPassword)
        {
            param = new ParamInfo();
            param.Key = "AdministratorPassword";
            param.Value = newPassword;
            facade.SaveParam(param);

            string url = "Default.aspx";
            if (!string.IsNullOrEmpty(Request["ReturnUrl"]))
            {
                url = Request["ReturnUrl"];
            }
            string msg = "修改密码成功!";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertChangePassword", "AlertAndRedirect('" + msg + "', '" + url + "');", true);
        }
        else
        {
            lblMessage.Text = "旧密码输入不正确。";
            return;
        }
    }
    protected void lbtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            ParamFacade facade = new ParamFacade();
            ParamInfo paraInfo = new ParamInfo();

            paraInfo.Key = "SiteName";
            paraInfo.Value = txtSiteName.Text;
            facade.SaveParam(paraInfo);
            Application["SiteName"] = null;

            paraInfo.Key = "LogoFileName";
            paraInfo.Value = txtLogoFileName.Text;
            facade.SaveParam(paraInfo);
            Application["LogoFileName"] = null;

            paraInfo.Key = "Address";
            paraInfo.Value = txtAddress.Text;
            facade.SaveParam(paraInfo);
            Application["Address"] = null;

            paraInfo.Key = "PhoneNumber";
            paraInfo.Value = txtPhone.Text;
            facade.SaveParam(paraInfo);
            Application["PhoneNumber"] = null;

            paraInfo.Key = "FaxNumber";
            paraInfo.Value = txtFax.Text;
            facade.SaveParam(paraInfo);
            Application["FaxNumber"] = null;

            paraInfo.Key = "QQNumber";
            paraInfo.Value = txtQQ.Text;
            facade.SaveParam(paraInfo);
            Application["QQNumber"] = null;

            paraInfo.Key = "NoticeDelay";
            paraInfo.Value = txtDelay.Text;
            facade.SaveParam(paraInfo);
            Application["NoticeDelay"] = null;

            paraInfo.Key = "AutoPlayMusic";
            paraInfo.Value = cbAutoMusic.Checked ? "1" : "0";
            facade.SaveParam(paraInfo);
            Application["AutoPlayMusic"] = null;

            JavascriptAlertAndRedirectAndRefreshParent("保存系统参数成功!", Request.Url.AbsoluteUri);
        }
        catch (Exception ex)
        {
            JavascriptAlert(ex.Message);
        }
    }
示例#3
0
        private void ParamConfigOperate(byte[] bField, ref int pos, ref int lenth, ParamInfo info)
        {
            string index = GetString(bField, pos, 2);

            pos   += 2;
            lenth += 2;
            switch (index)
            {
            case "29":    //pos终端号
                lenth           = 8;
                info.TerminalNo = GetString(bField, pos, lenth);
                break;

            case "11":
            case "12":
                lenth = 2;
                break;

            case "13":
                lenth = 1;
                break;

            case "14":
                lenth     = 14;
                info.Tel1 = GetString(bField, pos, lenth);
                break;

            case "15":
                lenth     = 14;
                info.Tel2 = GetString(bField, pos, lenth);
                break;

            case "16":
                lenth     = 14;
                info.Tel3 = GetString(bField, pos, lenth);
                break;

            case "17":
                lenth = 14;
                break;

            case "18":
                lenth = 1;
                break;

            case "19":
                lenth = 2;
                break;

            case "20":
            case "21":
                lenth = 1;
                break;

            case "22":
                lenth             = 40;
                info.MerchantName = GetString(bField, pos, lenth);
                break;

            case "23":
            case "24":
            case "25":
                lenth = 1;
                break;

            case "26":
                lenth = 8;
                byte[] tempB = new byte[8];
                Array.Copy(bField, pos, tempB, 0, 8);
                info.SupportType = Utility.bcd2str(tempB, lenth);
                break;

            case "27":
                lenth = 40;
                info.MerchantNameE = GetString(bField, pos, lenth);
                break;

            case "28":
                lenth           = 15;
                info.MerchantNo = GetString(bField, pos, lenth);
                break;

            case "30":
                lenth = 6;
                break;

            case "31":
                lenth = 6;
                break;

            case "32":
                lenth            = 19;
                info.BankCardNo1 = GetString(bField, pos, lenth).Trim();
                break;

            case "33":
                lenth            = 19;
                info.BankCardNo2 = GetString(bField, pos, lenth);
                break;

            case "34":
                lenth            = 19;
                info.BankCardNo3 = GetString(bField, pos, lenth);
                break;

            case "35":
                lenth = 2;
                break;

            case "36":
                lenth = 12;
                break;

            case "37":
                lenth         = 12;
                info.PayLimit = GetString(bField, pos, lenth);
                break;

            case "38":
                lenth = 12;
                break;

            case "39":
                lenth           = 12;
                info.TransLimit = GetString(bField, pos, lenth);
                break;

            case "40":
                lenth = 2;
                break;
            }
        }
示例#4
0
        public static List<ImageInfo> GetBartenderServicePrint(PrintItem currentPrinItem)
        {
            List<ImageInfo> result = null;
            if (!string.IsNullOrEmpty(currentPrinItem.TemplateName) &&
                 !string.IsNullOrEmpty(currentPrinItem.SpName) &&
                 currentPrinItem.PrintMode == 4)
            {

                List<ParamInfo> inputParas = new List<ParamInfo>();
                for (int i = 0; i < currentPrinItem.ParameterKeys.Count; i++)
                {
                    ParamInfo newParam = new ParamInfo();
                    newParam.ParamName = currentPrinItem.ParameterKeys[i];
                    newParam.Values = currentPrinItem.ParameterValues[i];
                    inputParas.Add(newParam);
                }

                inputParas.Add(new ParamInfo
                {
                    ParamName = "@Bartender",
                    Values = new List<string> { currentPrinItem.TemplateName }
                });

                string templateName = currentPrinItem.TemplateName + "~" + currentPrinItem.SpName;
                if (string.IsNullOrEmpty(currentPrinItem.dpi))
                {
                    result = getbartenderManager().getImageListForPrint(templateName, null, inputParas, false);
                }
                else
                {
                    result = getbartenderManager().getImageListForPrint(templateName, null, inputParas, false, currentPrinItem.dpi);
                }

            }
            return result;

        }
示例#5
0
        private PEPropertySymbol(
            PEModuleSymbol moduleSymbol,
            PENamedTypeSymbol containingType,
            PropertyDefinitionHandle handle,
            PEMethodSymbol getMethod,
            PEMethodSymbol setMethod,
            int countOfCustomModifiers,
            ParamInfo<TypeSymbol>[] propertyParams,
            MetadataDecoder metadataDecoder)
        {
            _containingType = containingType;
            var module = moduleSymbol.Module;
            PropertyAttributes mdFlags = 0;
            BadImageFormatException mrEx = null;

            try
            {
                module.GetPropertyDefPropsOrThrow(handle, out _name, out mdFlags);
            }
            catch (BadImageFormatException e)
            {
                mrEx = e;

                if ((object)_name == null)
                {
                    _name = string.Empty;
                }
            }

            _getMethod = getMethod;
            _setMethod = setMethod;
            _handle = handle;

            SignatureHeader unusedCallingConvention;
            BadImageFormatException getEx = null;
            var getMethodParams = (object)getMethod == null ? null : metadataDecoder.GetSignatureForMethod(getMethod.Handle, out unusedCallingConvention, out getEx);
            BadImageFormatException setEx = null;
            var setMethodParams = (object)setMethod == null ? null : metadataDecoder.GetSignatureForMethod(setMethod.Handle, out unusedCallingConvention, out setEx);

            // NOTE: property parameter names are not recorded in metadata, so we have to
            // use the parameter names from one of the indexers
            // NB: prefer setter names to getter names if both are present.
            bool isBad;
            _parameters = GetParameters(moduleSymbol, this, propertyParams, setMethodParams ?? getMethodParams, out isBad);

            if (getEx != null || setEx != null || mrEx != null || isBad)
            {
                _lazyUseSiteDiagnostic = new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this);
            }

            var returnInfo = propertyParams[0];
            _refKind = returnInfo.IsByRef ? RefKind.Ref : RefKind.None;

            // CONSIDER: Can we make parameter type computation lazy?
            TypeSymbol originalPropertyType = returnInfo.Type;
            _propertyType = DynamicTypeDecoder.TransformType(originalPropertyType, countOfCustomModifiers, handle, moduleSymbol, _refKind);

            // Dynamify object type if necessary
            _propertyType = _propertyType.AsDynamicIfNoPia(_containingType);

            _propertyType = TupleTypeDecoder.DecodeTupleTypesIfApplicable(_propertyType, handle, moduleSymbol);

            // A property is bogus and must be accessed by calling its accessors directly if the
            // accessor signatures do not agree, both with each other and with the property,
            // or if it has parameters and is not an indexer or indexed property.
            bool callMethodsDirectly = !DoSignaturesMatch(module, metadataDecoder, propertyParams, _getMethod, getMethodParams, _setMethod, setMethodParams) ||
                MustCallMethodsDirectlyCore();

            if (!callMethodsDirectly)
            {
                if ((object)_getMethod != null)
                {
                    _getMethod.SetAssociatedProperty(this, MethodKind.PropertyGet);
                }

                if ((object)_setMethod != null)
                {
                    _setMethod.SetAssociatedProperty(this, MethodKind.PropertySet);
                }
            }

            if (callMethodsDirectly)
            {
                _flags |= Flags.CallMethodsDirectly;
            }

            if ((mdFlags & PropertyAttributes.SpecialName) != 0)
            {
                _flags |= Flags.IsSpecialName;
            }

            if ((mdFlags & PropertyAttributes.RTSpecialName) != 0)
            {
                _flags |= Flags.IsRuntimeSpecialName;
            }
        }
        void ProcessContractDescription()
        {
            UInt32 dispIndex = 10;
            Dictionary<string, ParamInfo> paramDictionary = null;

            foreach (OperationDescription opDesc in contract.Operations)
            {
                dispToName[dispIndex] = opDesc.Name;
                nameToDisp[opDesc.Name] = dispIndex;
                MethodInfo methodInfo = null;
                methodInfo = new MethodInfo(opDesc);
                dispToOperationDescription[dispIndex++] = methodInfo;
                paramDictionary = new Dictionary<string, ParamInfo>();
                bool inVars = true;
                inVars = true;
                int paramCount = 0;

                foreach (MessageDescription msgDesc in opDesc.Messages)
                {
                    paramCount = 0;


                    if (msgDesc.Body.ReturnValue != null)
                    {
                        if (string.IsNullOrEmpty(msgDesc.Body.ReturnValue.BaseType))
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.CannotResolveTypeForParamInMessageDescription, "ReturnValue", msgDesc.Body.WrapperName, msgDesc.Body.WrapperNamespace), HR.DISP_E_MEMBERNOTFOUND));

                        msgDesc.Body.ReturnValue.Type = Type.GetType(msgDesc.Body.ReturnValue.BaseType);
                    }
                    foreach (MessagePartDescription param in msgDesc.Body.Parts)
                    {

                        UInt32 dispID = 0;
                        ParamInfo paramInfo = null;
                        paramInfo = null;
                        if (!nameToDisp.TryGetValue(param.Name, out dispID))
                        {

                            dispToName[dispIndex] = param.Name;
                            nameToDisp[param.Name] = dispIndex;
                            dispID = dispIndex;
                            dispIndex++;
                        }
                        if (!paramDictionary.TryGetValue(param.Name, out paramInfo))
                        {

                            paramInfo = new ParamInfo();
                            methodInfo.paramList.Add(paramInfo);
                            methodInfo.dispIdToParamInfo[dispID] = paramInfo;
                            if (string.IsNullOrEmpty(param.BaseType))
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.CannotResolveTypeForParamInMessageDescription, param.Name, msgDesc.Body.WrapperName, msgDesc.Body.WrapperNamespace), HR.DISP_E_MEMBERNOTFOUND));
                            paramInfo.type = Type.GetType(param.BaseType, true);
                            paramInfo.name = param.Name;
                            paramDictionary[param.Name] = paramInfo;
                            param.Index = paramCount;


                        }
                        param.Type = paramInfo.type;
                        if (inVars)
                        {
                            paramInfo.inIndex = paramCount;
                        }
                        else
                        {
                            paramInfo.outIndex = paramCount;

                        }

                        paramCount++;


                    }

                    inVars = false;

                }

            }

        }
 internal void CopyFrom(ParamInfo other)
 {
     Type = other.Type;
     Key = other.Key.Clone();
     Value = other.Value.Clone();
 }
示例#8
0
        private static ImmutableArray<ParameterSymbol> GetParameters(
            PEModuleSymbol moduleSymbol,
            PEPropertySymbol property,
            ParamInfo<TypeSymbol>[] propertyParams,
            ParamInfo<TypeSymbol>[] accessorParams,
            out bool anyParameterIsBad)
        {
            anyParameterIsBad = false;

            // First parameter is the property type.
            if (propertyParams.Length < 2)
            {
                return ImmutableArray<ParameterSymbol>.Empty;
            }

            var numAccessorParams = accessorParams.Length;

            var parameters = new ParameterSymbol[propertyParams.Length - 1];
            for (int i = 1; i < propertyParams.Length; i++) // from 1 to skip property/return type
            {
                // NOTE: this is a best guess at the Dev10 behavior.  The actual behavior is
                // in the unmanaged helper code that Dev10 uses to load the metadata.
                var propertyParam = propertyParams[i];
                var paramHandle = i < numAccessorParams ? accessorParams[i].Handle : propertyParam.Handle;
                var ordinal = i - 1;
                bool isBad;
                parameters[ordinal] = PEParameterSymbol.Create(moduleSymbol, property, ordinal, paramHandle, propertyParam, out isBad);

                if (isBad)
                {
                    anyParameterIsBad = true;
                }
            }
            return parameters.AsImmutableOrNull();
        }
 public override IStoryCommand Clone()
 {
     ObjAnimationParamCommand cmd = new ObjAnimationParamCommand();
     cmd.m_ObjId = m_ObjId.Clone();
     for (int i = 0; i < m_Params.Count; ++i) {
         ParamInfo param = new ParamInfo();
         param.CopyFrom(m_Params[i]);
         cmd.m_Params.Add(param);
     }
     return cmd;
 }
 protected override void Load(Dsl.FunctionData funcData)
 {
     Dsl.CallData callData = funcData.Call;
     if (null != callData) {
         Load(callData);
         for (int i = 0; i < funcData.Statements.Count; ++i) {
             Dsl.ISyntaxComponent statement = funcData.Statements[i];
             Dsl.CallData stCall = statement as Dsl.CallData;
             if (null != stCall && stCall.GetParamNum() >= 2) {
                 string id = stCall.GetId();
                 ParamInfo param = new ParamInfo(id, stCall.GetParam(0), stCall.GetParam(1));
                 m_Params.Add(param);
             }
         }
     }
 }
        private static bool ReturnTypesMatch(MethodSymbol candidateMethod, TypeMap candidateMethodTypeMap, ref ParamInfo targetReturnParam)
        {
            TypeSymbol candidateReturnType = candidateMethod.ReturnType;
            TypeSymbol targetReturnType = targetReturnParam.Type;

            // CONSIDER: Do we want to add special handling for error types?  Right now, we expect they'll just fail to match.
            if (candidateMethodTypeMap.SubstituteType(candidateReturnType) != targetReturnType)
            {
                return false;
            }

            if (!CustomModifiersMatch(candidateMethod.ReturnTypeCustomModifiers, targetReturnParam.CustomModifiers))
            {
                return false;
            }

            return true;
        }
 private void ProcessContractDescription()
 {
     uint num = 10;
     Dictionary<string, ParamInfo> dictionary = null;
     foreach (OperationDescription description in this.contract.Operations)
     {
         this.dispToName[num] = description.Name;
         this.nameToDisp[description.Name] = num;
         MethodInfo info = null;
         info = new MethodInfo(description);
         this.dispToOperationDescription[num++] = info;
         dictionary = new Dictionary<string, ParamInfo>();
         bool flag = true;
         flag = true;
         int num2 = 0;
         foreach (MessageDescription description2 in description.Messages)
         {
             num2 = 0;
             if (description2.Body.ReturnValue != null)
             {
                 if (string.IsNullOrEmpty(description2.Body.ReturnValue.BaseType))
                 {
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("CannotResolveTypeForParamInMessageDescription", new object[] { "ReturnValue", description2.Body.WrapperName, description2.Body.WrapperNamespace }), HR.DISP_E_MEMBERNOTFOUND));
                 }
                 description2.Body.ReturnValue.Type = Type.GetType(description2.Body.ReturnValue.BaseType);
             }
             foreach (MessagePartDescription description3 in description2.Body.Parts)
             {
                 uint num3 = 0;
                 ParamInfo info2 = null;
                 info2 = null;
                 if (!this.nameToDisp.TryGetValue(description3.Name, out num3))
                 {
                     this.dispToName[num] = description3.Name;
                     this.nameToDisp[description3.Name] = num;
                     num3 = num;
                     num++;
                 }
                 if (!dictionary.TryGetValue(description3.Name, out info2))
                 {
                     info2 = new ParamInfo();
                     info.paramList.Add(info2);
                     info.dispIdToParamInfo[num3] = info2;
                     if (string.IsNullOrEmpty(description3.BaseType))
                     {
                         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("CannotResolveTypeForParamInMessageDescription", new object[] { description3.Name, description2.Body.WrapperName, description2.Body.WrapperNamespace }), HR.DISP_E_MEMBERNOTFOUND));
                     }
                     info2.type = Type.GetType(description3.BaseType, true);
                     info2.name = description3.Name;
                     dictionary[description3.Name] = info2;
                     description3.Index = num2;
                 }
                 description3.Type = info2.type;
                 if (flag)
                 {
                     info2.inIndex = num2;
                 }
                 else
                 {
                     info2.outIndex = num2;
                 }
                 num2++;
             }
             flag = false;
         }
     }
 }
        private IEnumerable<ParamInfo> ScrapeParameters(IEnumerable<PSToken> tokens)
        {
            int groupDepth = 0;
            var paramTokens = new List<PSToken>();

            var filteredTokens = tokens
                .Where(t => t.Type != PSTokenType.Comment && t.Type != PSTokenType.NewLine);

            foreach (var token in filteredTokens)
            {
                paramTokens.Add(token);

                if (token.Type == PSTokenType.GroupStart && token.Content == "(")
                    groupDepth++;

                if (token.Type == PSTokenType.GroupEnd && token.Content == ")")
                {
                    groupDepth--;
                    if (groupDepth <= 0)
                        break;
                }
            }

            var currentParam = new ParamInfo();

            bool expectDefaultValue = false;

            foreach (var token in paramTokens)
            {
                if (token.Type == PSTokenType.Operator && token.Content != "=")
                {
                    expectDefaultValue = false;
                    if (currentParam.Name != null)
                        yield return currentParam;

                    currentParam = new ParamInfo();
                    continue;
                }

                if (expectDefaultValue)
                {
                    currentParam.DefaultValue = token.Content;
                    expectDefaultValue = false;
                    continue;
                }

                if (token.Type == PSTokenType.Type)
                {
                    var match = ParameterTypeRegex.Value.Match(token.Content ?? string.Empty);
                    if (match.Success)
                        currentParam.Type = match.Groups[1].Value;
                }

                if (token.Type == PSTokenType.Variable)
                    currentParam.Name = token.Content;

                if (token.Type == PSTokenType.Operator && token.Content == "=")
                {
                    expectDefaultValue = true;
                    continue;
                }
            }

            if (currentParam.Name != null)
                yield return currentParam;
        }
示例#14
0
 internal static PEParameterSymbol Create(
     PEModuleSymbol moduleSymbol,
     PEMethodSymbol containingSymbol,
     int ordinal,
     ParamInfo<TypeSymbol> parameter,
     out bool isBad)
 {
     return Create(moduleSymbol, containingSymbol, ordinal, parameter.IsByRef, parameter.RefCustomModifiers, parameter.Type, parameter.Handle, parameter.CustomModifiers, out isBad);
 }
示例#15
0
 /// <summary>
 /// Construct a parameter symbol for a property loaded from metadata.
 /// </summary>
 /// <param name="moduleSymbol"></param>
 /// <param name="containingSymbol"></param>
 /// <param name="ordinal"></param>
 /// <param name="handle">The property parameter doesn't have a name in metadata,
 /// so this is the handle of a corresponding accessor parameter, if there is one,
 /// or of the ParamInfo passed in, otherwise).</param>
 /// <param name="isBad" />
 /// <param name="parameter"></param>
 internal PEParameterSymbol(
     PEModuleSymbol moduleSymbol,
     PEPropertySymbol containingSymbol,
     int ordinal,
     ParameterHandle handle,
     ParamInfo<TypeSymbol> parameter,
     out bool isBad)
     : this(moduleSymbol, containingSymbol, ordinal, parameter.IsByRef, parameter.HasByRefBeforeCustomModifiers, parameter.Type, handle, parameter.CustomModifiers, out isBad)
 {
 }
示例#16
0
        private static bool DoSignaturesMatch(
            PEModule module,
            MetadataDecoder metadataDecoder,
            ParamInfo<TypeSymbol>[] propertyParams,
            PEMethodSymbol getMethod,
            ParamInfo<TypeSymbol>[] getMethodParams,
            PEMethodSymbol setMethod,
            ParamInfo<TypeSymbol>[] setMethodParams)
        {
            Debug.Assert((getMethodParams == null) == ((object)getMethod == null));
            Debug.Assert((setMethodParams == null) == ((object)setMethod == null));

            bool hasGetMethod = getMethodParams != null;
            bool hasSetMethod = setMethodParams != null;

            if (hasGetMethod && !metadataDecoder.DoPropertySignaturesMatch(propertyParams, getMethodParams, comparingToSetter: false, compareParamByRef: true, compareReturnType: true))
            {
                return false;
            }

            if (hasSetMethod && !metadataDecoder.DoPropertySignaturesMatch(propertyParams, setMethodParams, comparingToSetter: true, compareParamByRef: true, compareReturnType: true))
            {
                return false;
            }

            if (hasGetMethod && hasSetMethod)
            {
                var lastPropertyParamIndex = propertyParams.Length - 1;
                var getHandle = getMethodParams[lastPropertyParamIndex].Handle;
                var setHandle = setMethodParams[lastPropertyParamIndex].Handle;
                var getterHasParamArray = !getHandle.IsNil && module.HasParamsAttribute(getHandle);
                var setterHasParamArray = !setHandle.IsNil && module.HasParamsAttribute(setHandle);
                if (getterHasParamArray != setterHasParamArray)
                {
                    return false;
                }

                if ((getMethod.IsExtern != setMethod.IsExtern) ||
                    // (getMethod.IsAbstract != setMethod.IsAbstract) || // NOTE: Dev10 accepts one abstract accessor
                    (getMethod.IsSealed != setMethod.IsSealed) ||
                    (getMethod.IsOverride != setMethod.IsOverride) ||
                    (getMethod.IsStatic != setMethod.IsStatic))
                {
                    return false;
                }
            }

            return true;
        }
示例#17
0
 public ParamInfo AddParam(string name, string typeName)
 {
     Raise<ArgumentException>.If(_params.Any(p => p.Name == name));
     var paramInfo = new ParamInfo(name, typeName);
     _params.Add(paramInfo);
     return paramInfo;
 }
示例#18
0
 public PEPropertySymbolWithCustomModifiers(
     PEModuleSymbol moduleSymbol,
     PENamedTypeSymbol containingType,
     PropertyDefinitionHandle handle,
     PEMethodSymbol getMethod,
     PEMethodSymbol setMethod,
     ParamInfo<TypeSymbol>[] propertyParams,
     MetadataDecoder metadataDecoder)
     : base (moduleSymbol, containingType, handle, getMethod, setMethod,
             propertyParams[0].CustomModifiers.NullToEmpty().Length + propertyParams[0].RefCustomModifiers.NullToEmpty().Length,
             propertyParams, metadataDecoder)
 {
     var returnInfo = propertyParams[0];
     _typeCustomModifiers = CSharpCustomModifier.Convert(returnInfo.CustomModifiers);
     _refCustomModifiers = CSharpCustomModifier.Convert(returnInfo.RefCustomModifiers);
 }
        private static MethodSymbol FindMethodBySignature(TypeSymbol targetTypeSymbol, string targetMemberName, SignatureHeader targetMemberSignatureHeader, int targetMemberTypeParamCount, ParamInfo<TypeSymbol>[] targetParamInfo)
        {
            foreach (Symbol member in targetTypeSymbol.GetMembers(targetMemberName))
            {
                var method = member as MethodSymbol;
                if ((object)method != null &&
                    ((byte)method.CallingConvention == targetMemberSignatureHeader.RawValue) &&
                    (targetMemberTypeParamCount == method.Arity) &&
                    MethodSymbolMatchesParamInfo(method, targetParamInfo))
                {
                    // Behavior in the face of multiple matching signatures is
                    // implementation defined - we'll just pick the first one.
                    return method;
                }
            }

            return null;
        }
示例#20
0
        private void InitializeGrid()
        {
            Grid.Rows.Clear ();
            Grid.Columns.Clear ();
            _paramInfos = new List<ParamInfo> ();

            //
            // Image Column
            //
            _resultImageColIndex = Grid.Columns.Count;
            Grid.Columns.Add (new DataGridViewImageColumn {
                Width = 20,
                MinimumWidth = 20,
                ReadOnly = true,
                Image = AllImages.Images[NewStatusIcon],
                CellTemplate = new DefaultImageCell {
                    Image = AllImages.Images[NewStatusIcon],
                    Style = new DataGridViewCellStyle {
                        Alignment = DataGridViewContentAlignment.TopCenter,
                    },
                },
            });

            //
            // this Column
            //
            if (_funcElm.IsShared) {
                _thisColIndex = -1;
            }
            else {
                _thisColIndex = Grid.Columns.Count;
                Grid.Columns.Add ("this", "this");
            }

            //
            // Parameters Column
            //
            if (_testType == TestType.PropertySetter) {
                var pi = new ParamInfo {
                    Name = "value",
                    ColIndex = Grid.Columns.Count,
                    ParameterType = GetTypeName (_funcElm.Type),
                };
                _paramInfos.Add (pi);
                Grid.Columns.Add (pi.Name, pi.Name);
            }
            else {
                foreach (CodeParameter2 p in _funcElm.Parameters) {
                    var pi = new ParamInfo {
                        Name = p.Name,
                        ColIndex = Grid.Columns.Count,
                        ParameterType = GetTypeName (p.Type),
                    };
                    _paramInfos.Add (pi);
                    Grid.Columns.Add (pi.Name, pi.Name);
                }
            }

            //
            // Value and Expected Value Columns
            //
            if (_testType == TestType.Procedure || _testType == TestType.PropertySetter) {
                _resultColIndex = -1;
                _expectedColIndex = -1;
            }
            else {
                _resultColIndex = Grid.Columns.Count;
                Grid.Columns.Add (_funcElm.Name, _funcElm.Name);
                Grid.Columns[_resultColIndex].ReadOnly = true;

                _expectedColIndex = Grid.Columns.Count;
                Grid.Columns.Add ("E" + _funcElm.Name, "E[" + _funcElm.Name + "]");
            }

            //
            // Assert Column
            //
            _assertColIndex = Grid.Columns.Count;
            Grid.Columns.Add ("Assert", "Assert");

            //
            // Fail Column
            //
            _failColIndex = Grid.Columns.Count;
            Grid.Columns.Add ("Fail", "Fail");
            Grid.Columns[_failColIndex].ReadOnly = true;
            Grid.Columns[_failColIndex].Width *= 2;

            //
            // Format
            //
            _formattingCells = true;
            foreach (var col in Grid.Columns.OfType<DataGridViewColumn> ().Skip (1)) {
                col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                col.Width = _tests.DisplayInfo.GetColumnWidth (col.Name);
            }
            _formattingCells = false;
        }
        private static bool MethodSymbolMatchesParamInfo(MethodSymbol candidateMethod, ParamInfo<TypeSymbol>[] targetParamInfo)
        {
            int numParams = targetParamInfo.Length - 1; //don't count return type

            if (candidateMethod.ParameterCount != numParams)
            {
                return false;
            }

            // IndexedTypeParameterSymbol is not going to be exposed anywhere,
            // so we'll cheat and use it here for comparison purposes.
            TypeMap candidateMethodTypeMap = new TypeMap(
                candidateMethod.TypeParameters,
                IndexedTypeParameterSymbol.Take(candidateMethod.Arity), true);

            if (!ReturnTypesMatch(candidateMethod, candidateMethodTypeMap, ref targetParamInfo[0]))
            {
                return false;
            }

            for (int i = 0; i < numParams; i++)
            {
                if (!ParametersMatch(candidateMethod.Parameters[i], candidateMethodTypeMap, ref targetParamInfo[i + 1 /*for return type*/]))
                {
                    return false;
                }
            }

            return true;
        }
示例#22
0
        internal ParamInfo Method_GetParamInfo(long id)
        {
            var res = SendReceive(CommandSet.METHOD, (int)CmdMethod.GET_PARAM_INFO, new PacketWriter().WriteId(id));

            ParamInfo info = new ParamInfo();
            info.call_conv = res.ReadInt();
            info.param_count = res.ReadInt();
            info.generic_param_count = res.ReadInt();
            info.ret_type = res.ReadId();
            info.param_types = new long[info.param_count];
            for (int i = 0; i < info.param_count; ++i)
                info.param_types[i] = res.ReadId();
            info.param_names = new string[info.param_count];
            for (int i = 0; i < info.param_count; ++i)
                info.param_names[i] = res.ReadString();

            return info;
        }
        private static bool ParametersMatch(ParameterSymbol candidateParam, TypeMap candidateMethodTypeMap, ref ParamInfo<TypeSymbol> targetParam)
        {
            Debug.Assert(candidateMethodTypeMap != null);

            // This could be combined into a single return statement with a more complicated expression, but that would
            // be harder to debug.

            if ((candidateParam.RefKind != RefKind.None) != targetParam.IsByRef)
            {
                return false;
            }

            // CONSIDER: Do we want to add special handling for error types?  Right now, we expect they'll just fail to match.
            var substituted = new TypeWithModifiers(candidateParam.Type, candidateParam.CustomModifiers).SubstituteType(candidateMethodTypeMap);
            if (substituted.Type != targetParam.Type)
            {
                return false;
            }

            if (!CustomModifiersMatch(substituted.CustomModifiers, targetParam.CustomModifiers) ||
                !CustomModifiersMatch(candidateMethodTypeMap.SubstituteCustomModifiers(candidateParam.RefCustomModifiers), targetParam.RefCustomModifiers))
            {
                return false;
            }

            return true;
        }
示例#24
0
 internal MethodDefSignatureConverter(PEFileToObjectModel peFileToObjectModel, MethodDefinition moduleMethod, MemoryReader signatureMemoryReader)
   : base(peFileToObjectModel, signatureMemoryReader, moduleMethod) {
   //  TODO: Check minimum required size of the signature...
   this.FirstByte = this.SignatureMemoryReader.ReadByte();
   if (SignatureHeader.IsGeneric(this.FirstByte)) {
     this.GenericParamCount = (uint)this.SignatureMemoryReader.ReadCompressedUInt32();
   }
   this.paramCount = this.SignatureMemoryReader.ReadCompressedUInt32();
   bool dummyPinned;
   this.ReturnCustomModifiers = this.GetCustomModifiers(out dummyPinned);
   byte retByte = this.SignatureMemoryReader.PeekByte(0);
   bool isReturnByReference = false;
   if (retByte == ElementType.Void) {
     this.ReturnTypeReference = peFileToObjectModel.PlatformType.SystemVoid;
     this.SignatureMemoryReader.SkipBytes(1);
   } else if (retByte == ElementType.TypedReference) {
     this.ReturnTypeReference = peFileToObjectModel.PlatformType.SystemTypedReference;
     this.SignatureMemoryReader.SkipBytes(1);
   } else {
     if (retByte == ElementType.ByReference) {
       isReturnByReference = true;
       this.SignatureMemoryReader.SkipBytes(1);
     }
     this.ReturnTypeReference = this.GetTypeReference();
   }
   PEFileReader peFileReader = peFileToObjectModel.PEFileReader;
   uint paramRowCount;
   uint paramRowStart = peFileReader.GetParamInformation(moduleMethod.MethodDefRowId, out paramRowCount);
   uint paramRowEnd = paramRowStart + paramRowCount;
   ParamInfo[] paramInfoArray = new ParamInfo[paramRowCount];
   if (peFileReader.UseParamPtrTable) {
     for (uint paramRowIter = paramRowStart; paramRowIter < paramRowEnd; ++paramRowIter) {
       uint paramRowId = peFileReader.ParamPtrTable.GetParamFor(paramRowIter);
       ParamRow paramRow = peFileReader.ParamTable[paramRowId];
       //  TODO: Error check if seqence is in proper range...
       paramInfoArray[paramRowId - paramRowStart] = new ParamInfo(paramRowId, paramRow.Sequence, peFileToObjectModel.GetNameFromOffset(paramRow.Name), paramRow.Flags);
     }
   } else {
     for (uint paramRowId = paramRowStart; paramRowId < paramRowEnd; ++paramRowId) {
       ParamRow paramRow = peFileReader.ParamTable[paramRowId];
       //  TODO: Error check if seqence is in proper range...
       paramInfoArray[paramRowId - paramRowStart] = new ParamInfo(paramRowId, paramRow.Sequence, peFileToObjectModel.GetNameFromOffset(paramRow.Name), paramRow.Flags);
     }
   }
   if (paramRowCount > 0 && paramInfoArray[0].ParamSequence == 0) {
     ParamFlags paramFlag = paramInfoArray[0].ParamFlags;
     if (isReturnByReference) {
       paramFlag |= ParamFlags.ByReference;
     }
     this.ReturnParameter = new ReturnParameter(this.PEFileToObjectModel, paramInfoArray[0].ParamName, paramFlag, paramInfoArray[0].ParamRowId);
   } else {
     this.ReturnParameter = new ReturnParameter(this.PEFileToObjectModel, Dummy.Name, isReturnByReference ? ParamFlags.ByReference : 0, 0);
   }
   this.ParamInfoArray = paramInfoArray;
   if (this.paramCount > 0) {
     IParameterDefinition[] moduleParamArr = this.GetModuleParameters(true, moduleMethod, this.paramCount);
     this.paramCount = moduleParamArr.Length;
     if (this.paramCount > 0) this.Parameters = moduleParamArr;
   }
 }
        private static bool ReturnTypesMatch(MethodSymbol candidateMethod, TypeMap candidateMethodTypeMap, ref ParamInfo<TypeSymbol> targetReturnParam)
        {
            Debug.Assert(candidateMethodTypeMap != null);

            if (candidateMethod.ReturnsByRef != targetReturnParam.IsByRef)
            {
                return false;
            }

            TypeSymbol candidateReturnType = candidateMethod.ReturnType;
            TypeSymbol targetReturnType = targetReturnParam.Type;

            // CONSIDER: Do we want to add special handling for error types?  Right now, we expect they'll just fail to match.
            var substituted = new TypeWithModifiers(candidateReturnType, candidateMethod.ReturnTypeCustomModifiers).SubstituteType(candidateMethodTypeMap);
            if (substituted.Type != targetReturnType)
            {
                return false;
            }

            if (!CustomModifiersMatch(substituted.CustomModifiers, targetReturnParam.CustomModifiers) ||
                !CustomModifiersMatch(candidateMethodTypeMap.SubstituteCustomModifiers(candidateMethod.RefCustomModifiers), targetReturnParam.RefCustomModifiers))
            {
                return false;
            }

            return true;
        }
示例#26
0
        //public static string GetBartenderPrint(PrintItem currentPrinItem, string pCode)
        //{
        //    string batFilePath = System.Configuration.ConfigurationManager.AppSettings["ClientBatFilePath"];
        //    string result = null;
        //    if (!string.IsNullOrEmpty(currentPrinItem.SpName) && currentPrinItem.PrintMode == 3)
        //    {
        //        result = getPrintService().GetMainBat(currentPrinItem.SpName, currentPrinItem.ParameterKeys, currentPrinItem.ParameterValues);
        //    }
        //    return result;

        //}

        public static List<ImageInfo> GetTemplatePrint(PrintItem currentPrinItem, Boolean isPrintRoom)
        {
            List<ImageInfo> result = null;
            if (!string.IsNullOrEmpty(currentPrinItem.TemplateName) && currentPrinItem.PrintMode == 1)
            {

                List<ParamInfo> inputParas = new List<ParamInfo>();
                for (int i = 0; i < currentPrinItem.ParameterKeys.Count; i++)
                {
                    ParamInfo newParam = new ParamInfo();
                    newParam.ParamName = currentPrinItem.ParameterKeys[i];
                    newParam.Values = currentPrinItem.ParameterValues[i];
                    inputParas.Add(newParam);
                }

                if (isPrintRoom)
                {
                    if (string.IsNullOrEmpty(currentPrinItem.dpi))
                    {

                        result = getPrintRoomLlbManager().getImageListForPrint(currentPrinItem.TemplateName, null, inputParas, isPrintRoom);
                    }
                    else
                    {
                        result = getPrintRoomLlbManager().getImageListForPrint(currentPrinItem.TemplateName, null, inputParas, isPrintRoom, currentPrinItem.dpi);
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(currentPrinItem.dpi))
                    {

                        result = getCommonLlbManager().getImageListForPrint(currentPrinItem.TemplateName, null, inputParas, isPrintRoom);
                    }
                    else
                    {
                        result = getCommonLlbManager().getImageListForPrint(currentPrinItem.TemplateName, null, inputParas, isPrintRoom, currentPrinItem.dpi);
                    }
                }

            }
            return result;

        }       
示例#27
0
文件: spg76212.cs 项目: Prizmer/ps
        public bool readArchivesStructure(ushort paramNumber, ref List<ParamInfo> archStructure)
        {
            byte FNC = 0x19;

            byte[] paramBytes = stringToBytes(paramNumber.ToString());

            List<byte> messageBodyList = new List<byte>();
            messageBodyList.Add(HT);
            messageBodyList.AddRange(stringToBytes("0"));
            messageBodyList.Add(HT);
            messageBodyList.AddRange(paramBytes);
            messageBodyList.Add(FF);
            byte[] messageBodyArr = messageBodyList.ToArray();
            List<byte> answDataList = new List<byte>();
            if (!sendMessage(messageBodyArr, FNC, ref answDataList))
            {
                WriteToLog("readArchivesStructure: ошибка отправки сообщения");
                return false;
            }

            if (answDataList.Count < 2)
            {
                WriteToLog("readArchivesStructure: кол-во полученых данных меньше " +
                "минимально допустимого числа для данного запроса");
                return false;
            }

            List<byte[]> blocks = new List<byte[]>();
            if (!splitInfoBlocks(answDataList.ToArray(), ref blocks))
            {
                WriteToLog("readArchivesStructure: splitInfoBlocks fail");
                return false;
            }

            List<ParamInfo> pil = new List<ParamInfo>();
            bool exceptionFlag = false;
            int paramNumb = 4;
            for (int i = 0; i < blocks.Count; i++)
            {
                List<byte>[] values = new List<byte>[paramNumb];
                if (!getValueBytesFromInfoBlock(blocks[i], paramNumb, ref values))
                {
                    WriteToLog("readArchivesStructure: getValueBytesFromInfoBlock fail");
                    return false;
                }

                ParamInfo pi = new ParamInfo();
                try
                {
                    pi.caption = bytesToString(values[0].ToArray());
                    pi.units = bytesToString(values[1].ToArray());
                    pi.channelNumber = int.Parse(bytesToString(values[2].ToArray()));
                    pi.paramNumber = int.Parse(bytesToString(values[3].ToArray()));
                }
                catch (Exception ex)
                {
                    exceptionFlag = true;
                    WriteToLog("readArchivesStructure: ошибка преобразование байт в соответствующие единицы");
                }

                pil.Add(pi);
            }

            if (!exceptionFlag)
            {
                archStructure = pil;
                return true;
            }
            else return false;
        }
示例#28
0
 /// <summary>
 /// Construct a parameter symbol for a property loaded from metadata.
 /// </summary>
 /// <param name="moduleSymbol"></param>
 /// <param name="containingSymbol"></param>
 /// <param name="ordinal"></param>
 /// <param name="handle">The property parameter doesn't have a name in metadata,
 /// so this is the handle of a corresponding accessor parameter, if there is one,
 /// or of the ParamInfo passed in, otherwise).</param>
 /// <param name="isBad" />
 /// <param name="parameter"></param>
 internal static PEParameterSymbol Create(
     PEModuleSymbol moduleSymbol,
     PEPropertySymbol containingSymbol,
     int ordinal,
     ParameterHandle handle,
     ParamInfo<TypeSymbol> parameter,
     out bool isBad)
 {
     return Create(moduleSymbol, containingSymbol, ordinal, parameter.IsByRef, parameter.CountOfCustomModifiersPrecedingByRef, parameter.Type, handle, parameter.CustomModifiers, out isBad);
 }
示例#29
0
        private AstNode ParseMethod(AstNode qyInput)
        {
            ArrayList argList = new ArrayList();
            string    name    = this.scanner.Name;
            string    prefix  = this.scanner.Prefix;

            PassToken(XPathScanner.LexKind.Name);
            PassToken(XPathScanner.LexKind.LParens);
            if (this.scanner.Kind != XPathScanner.LexKind.RParens)
            {
                do
                {
                    argList.Add(ParseExpresion(qyInput));
                    if (this.scanner.Kind == XPathScanner.LexKind.RParens)
                    {
                        break;
                    }
                    PassToken(XPathScanner.LexKind.Comma);
                }while (true);
            }
            PassToken(XPathScanner.LexKind.RParens);
            if (prefix == string.Empty)
            {
                ParamInfo pi = (ParamInfo)functionTable[name];
                if (pi != null)
                {
                    int argCount = argList.Count;
                    if (argCount < pi.Minargs)
                    {
                        throw new XPathException(String.Format("Function '{0}' in '{1}' has invalid number of arguments.", name, this.scanner.SourceText));
                    }
                    if (pi.FType == Function.FunctionType.FuncConcat)
                    {
                        for (int i = 0; i < argCount; i++)
                        {
                            AstNode arg = (AstNode)argList[i];
                            if (arg.ReturnType != XPathResultType.String)
                            {
                                arg = new Function(Function.FunctionType.FuncString, arg);
                            }
                            argList[i] = arg;
                        }
                    }
                    else
                    {
                        if (pi.Maxargs < argCount)
                        {
                            throw new XPathException(String.Format("Function '{0}' in '{1}' has invalid number of arguments.", name, this.scanner.SourceText));
                        }
                        if (pi.ArgTypes.Length < argCount)
                        {
                            argCount = pi.ArgTypes.Length;    // argument we have the type specified (can be < pi.Minargs)
                        }
                        for (int i = 0; i < argCount; i++)
                        {
                            AstNode arg = (AstNode)argList[i];
                            if (
                                pi.ArgTypes[i] != XPathResultType.Any &&
                                pi.ArgTypes[i] != arg.ReturnType
                                )
                            {
                                switch (pi.ArgTypes[i])
                                {
                                case  XPathResultType.NodeSet:
                                    if (!(arg is Variable) && !(arg is Function && arg.ReturnType == XPathResultType.Error))
                                    {
                                        throw new XPathException(String.Format("Function '{0}' in '{1}' has invalid number of arguments.", name, this.scanner.SourceText));
                                    }
                                    break;

                                case  XPathResultType.String:
                                    arg = new Function(Function.FunctionType.FuncString, arg);
                                    break;

                                case  XPathResultType.Number:
                                    arg = new Function(Function.FunctionType.FuncNumber, arg);
                                    break;

                                case  XPathResultType.Boolean:
                                    arg = new Function(Function.FunctionType.FuncBoolean, arg);
                                    break;
                                }
                                argList[i] = arg;
                            }
                        }
                    }
                    return(new Function(pi.FType, argList));
                }
            }
            return(new Function(prefix, name, argList));
        }