Example #1
1
 public ASdu(TypeId typeId, bool isSequenceOfElements, int sequenceLength,
     CauseOfTransmission causeOfTransmission, bool test, bool negativeConfirm, int originatorAddress,
     int commonAddress, byte[] privateInformation)
 {
     this.typeId = typeId;
     IsSequenceOfElements = isSequenceOfElements;
     this.causeOfTransmission = causeOfTransmission;
     this.test = test;
     this.negativeConfirm = negativeConfirm;
     this.originatorAddress = originatorAddress;
     this.commonAddress = commonAddress;
     informationObjects = null;
     this.privateInformation = privateInformation;
     this.sequenceLength = sequenceLength;
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>Requests the retrieving of an advertisement. This function can only be used 
 /// in 2-legged-mode (To use when the OAuth token hasn't been included in the construction of the client).</summary>
 /// <param name="adSpace">The adSpace of the Bluevia application.</param>
 /// <param name="country">Country where the target user is located.
 /// Must follow <a href="http://www.iso.org/iso/country_codes.htm)">ISO-3166</a>.</param>
 /// <param name="targetUserId">Optional: Identifier of the Target User.</param>
 /// <param name="adRequestId">Optional: an unique id for the request.  
 /// (if it is not set, the SDK will generate it automatically).</param>
 /// <param name="adPresentation">Optional: The value is a code that represents the ad format type</param>
 /// <param name="keywords">Optional: If you wish to retrieve advertisings related to some keywords.</param>
 /// <param name="protectionPolicy">Optional: The adult control policy. It will be safe, low, high. 
 /// It should be checked with the application SLA in the Bluevia endpoint</param>
 /// <param name="userAgent">Optional: The user agent of the client. ("none" by default).</param>
 /// <returns>The result returned by the server that contains the advertising meta-data</returns>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public Schemas.SimpleAdResponse GetAdvertising2L(string adSpace, string country
     , string targetUserId = null
     , string adRequestId = null, TypeId adPresentation = 0, string[] keywords = null
     , ProtectionPolicy protectionPolicy = 0, string userAgent = "none")
 {
     return GetAdvertising2L(adSpace, country, targetUserId, adRequestId, adPresentation, keywords, protectionPolicy, userAgent, null);
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>This function translates the enumeration selection of the advertising TypeId (Image, Text),
 /// into the relative code needed to make the request.</summary>
 /// <param name="typeId">The selected TypeId (Image, Text).</param>
 /// <returns>The relative code of the selected advertising type: Image->0101; Text->0104.</returns>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static string TranslateTypeId(TypeId typeId)
 {
     switch (typeId)
     {
         case TypeId.image:
             return "0101";
         case TypeId.text:
             return "0104";
         default:
             return null;
     }
 }
Example #4
0
        public ASdu(TypeId typeId, bool isSequenceOfElements, CauseOfTransmission causeOfTransmission, bool test,
            bool negativeConfirm, int originatorAddress, int commonAddress, InformationObject[] informationObjects)
        {
            IsSequenceOfElements = isSequenceOfElements;

            this.typeId = typeId;
            this.causeOfTransmission = causeOfTransmission;
            this.test = test;
            this.negativeConfirm = negativeConfirm;
            this.originatorAddress = originatorAddress;
            this.commonAddress = commonAddress;
            this.informationObjects = informationObjects;

            privateInformation = null;

            sequenceLength = isSequenceOfElements
                ? informationObjects[0].GetInformationElements().Length
                : informationObjects.Length;
        }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>Creates a Full SimpleAdRequest from the single request's advertising fields.</summary>
 /// <param name="adSpace">Unique ID that identifies the ad-space, the place the ad is going to be placed within the 
 /// channel. This parameter should be unique for partner_id.</param>
 /// <param name="country">The requester's country.</param>
 /// <param name="targetUserId">The user identification.</param>
 /// <param name="adRequestId">Advertisement page Request Id identification.</param>
 /// <param name="adPresentation">Format of the target advertising space.</param>
 /// <param name="keywords">Array of keywords the ads are related to.</param>
 /// <param name="protectionPolicy">The adult control policy. It will be safe, low, high.</param>
 /// <param name="userAgent">The user agent of the user's navigator.</param>
 /// <returns>A full builded SimpleAdRequest ready to be serialized.</returns>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static Schemas.SimpleAdRequest CreateSimpleAdRequest(string adSpace, string country,
     string targetUserId, string adRequestId, TypeId adPresentation,
     string[] keywords, ProtectionPolicy protectionPolicy, string userAgent)
 {
     Schemas.SimpleAdRequest simpleAdRequest = new Schemas.SimpleAdRequest()
     {
         adSpace = adSpace,
         country = country,
         targetUserId = targetUserId,
         adRequestId = adRequestId,
         adPresentation = AdvertisingTools.TranslateTypeId(adPresentation),
         keywords = AdvertisingTools.ConvertKeywordsToString(keywords),
         protectionPolicy = Convert.ToString(protectionPolicy.GetHashCode()),
         userAgent = userAgent
     };
     //To avoid sending protection policy, if the developer hasn't specified it
     if (simpleAdRequest.protectionPolicy.Equals("0"))
     {
         simpleAdRequest.protectionPolicy = null;
     }
     return simpleAdRequest;
 }
Example #6
0
 /// <summary>
 ///     閣僚を書き出す
 /// </summary>
 /// <param name="typeId">閣僚のtypeとid</param>
 /// <param name="writer">ファイル書き込み用</param>
 private static void WriteMinister(TypeId typeId, TextWriter writer)
 {
     WriteTypeId(typeId, writer);
     Minister minister = Ministers.Items.Find(m => m.Id == typeId.Id);
     if (minister != null)
     {
         writer.WriteLine(" # {0}", minister.Name);
     }
     else
     {
         writer.WriteLine();
     }
 }
        private Type GetMockedType(TypeId id1, Type mockedType)
        {
            Type type1;
            if (createdTypes.ContainsKey(id1))
            {
                type1 = (Type) createdTypes[id1];
            }
            else
            {
                createdTypes[id1] =
                    type1 = CreateType("MockObjectType" + (createdTypes.Count + 1), mockedType);
            }

            return type1;
        }
Example #8
0
        /// <summary>
        ///     typeとidの組を削除する
        /// </summary>
        /// <param name="id">typeとidの組</param>
        /// <returns>削除に成功すればtrueを返す</returns>
        public static bool RemoveTypeId(TypeId id)
        {
            if (id == null)
            {
                return false;
            }

            if (!_usedTypeIds.ContainsKey(id.Type))
            {
                return false;
            }

            if (!_usedTypeIds[id.Type].Contains(id.Id))
            {
                return false;
            }
            _usedTypeIds[id.Type].Remove(id.Id);

            return true;
        }
        ShapeData GetNextShape(TypeId typeId)
        {
            ShapeData s = null;

            //typeCounts[(int)typeId]++;

            if (_shapeIndex >= _shapes.Count) {
                if (LogNewShapes) {
                    Debug.WriteLine("Adding shape " + typeId + " for " + _entity);
                }
                s = ConstructAndAddShape(typeId);
            }
            else if (_shapes[_shapeIndex].TypeId != typeId) {
                if (LogBadShapes) {
                    Debug.WriteLine("Bad shape " + _shapeIndex + "! Wanted " + typeId + " got " + _shapes[_shapeIndex].TypeId + " for " + _entity);
                }
                TrimShapes();
                s = ConstructAndAddShape(typeId);
            }
            else {
                s = _shapes[_shapeIndex];
            }

            _shapeIndex++;

            _lastShape = s;

            return s;
        }
            private bool ContainsSameTypesAs(TypeId other)
            {
                if (other.types.Length != types.Length)
                {
                    return false;
                }

                for (int i = 0; i < types.Length; i++)
                {
                    if (Array.IndexOf(other.types, types[i]) < 0)
                    {
                        return false;
                    }
                }

                return true;
            }
Example #11
0
        /// <summary>
        ///     typeとidの組を構文解析する
        /// </summary>
        /// <param name="lexer">字句解析器</param>
        /// <returns>typeとidの組</returns>
        private static TypeId ParseTypeId(TextLexer lexer)
        {
            // =
            Token token = lexer.GetToken();
            if (token.Type != TokenType.Equal)
            {
                Log.InvalidToken(LogCategory, token, lexer);
                return null;
            }

            // {
            token = lexer.GetToken();
            if (token.Type != TokenType.OpenBrace)
            {
                Log.InvalidToken(LogCategory, token, lexer);
                return null;
            }

            TypeId id = new TypeId();
            while (true)
            {
                token = lexer.GetToken();

                // ファイルの終端
                if (token == null)
                {
                    break;
                }

                // } (セクション終端)
                if (token.Type == TokenType.CloseBrace)
                {
                    break;
                }

                // 無効なトークン
                if (token.Type != TokenType.Identifier)
                {
                    Log.InvalidToken(LogCategory, token, lexer);
                    lexer.SkipLine();
                    continue;
                }

                string keyword = token.Value as string;
                if (string.IsNullOrEmpty(keyword))
                {
                    continue;
                }
                keyword = keyword.ToLower();

                // type
                if (keyword.Equals("type"))
                {
                    int? n = ParseInt(lexer);
                    if (!n.HasValue)
                    {
                        Log.InvalidClause(LogCategory, "type", lexer);
                        continue;
                    }

                    // type
                    id.Type = (int) n;
                    continue;
                }

                // id
                if (keyword.Equals("id"))
                {
                    int? n = ParseInt(lexer);
                    if (!n.HasValue)
                    {
                        Log.InvalidClause(LogCategory, "id", lexer);
                        continue;
                    }

                    // id
                    id.Id = (int) n;
                    continue;
                }

                // 無効なトークン
                Log.InvalidToken(LogCategory, token, lexer);
                lexer.SkipLine();
            }

            return id;
        }
        /// <summary>
        ///     項目変更前の処理 - 閣僚id
        /// </summary>
        /// <param name="control">typeのコントロール</param>
        /// <param name="settings">国家設定</param>
        /// <param name="typeId">typeとidの組</param>
        private void PreItemChangedCabinetId(TextBox control, CountrySettings settings, TypeId typeId)
        {
            typeId.Type = Scenarios.GetNewType(settings.HeadOfState?.Type ?? 1);

            // 編集済みフラグを設定する
            ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag;
            SetItemDirty(itemId, settings);

            // 編集項目の値を更新する
            UpdateItemValue(control, settings);

            // 編集項目の色を更新する
            UpdateItemColor(control, settings);
        }
Example #13
0
 /// <summary>
 ///     idを設定する
 /// </summary>
 /// <param name="typeId">typeとidの組</param>
 /// <param name="id">idの値</param>
 public static void SetId(TypeId typeId, int id)
 {
     RemoveTypeId(typeId);
     typeId.Id = id;
     AddTypeId(typeId);
 }
Example #14
0
 /// <summary>
 ///     typeとidの組を書き出す
 /// </summary>
 /// <param name="id">typeとidの組</param>
 /// <param name="writer">ファイル書き込み用</param>
 private static void WriteTypeId(TypeId id, TextWriter writer)
 {
     writer.Write("{{ type = {0} id = {1} }}", id.Type, id.Id);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TypeDefinition"/> class.
 /// </summary>
 /// <param name="typeName">Name of the type.</param>
 /// <param name="theTypeId">The type identifier.</param>
 public TypeDefinition(string typeName, TypeId theTypeId)
 {
     Name = typeName;
     TypeId = theTypeId;
 }
        /// <summary>
        /// Initializes a new instance of the TypeDefinition class. Construction is
        /// completed using FinishConstruction
        /// </summary>
        /// <param name="theNode"></param>
        /// <param name="theTypeId"></param>
        public TypeDefinition(XElement theNode, TypeId theTypeId)
        {
            if (theNode.Element("Name") != null)
            {
                Name = theNode.Element("Name").Value;
            }

            if (theNode.Element("Ref") != null)
            {
                Ref = Formatting.ParseInt(theNode.Element("Ref").Value);
            }

            TypeId = theTypeId;
        }
Example #17
0
 /// 仮想メソッド
 ///---------------------------------------------------------------------------
 /// 初期化
 public virtual bool Init( int num )
 {
     ShapeType = TypeId.Non;
     return false;
 }
            private bool ContainsSameTypesAs(TypeId other)
            {
                if (other.types.Length != this.types.Length)
                {
                    return false;
                }

                for (int num1 = 0; num1 < this.types.Length; num1++)
                {
                    if (Array.IndexOf(other.types, this.types[num1]) < 0)
                    {
                        return false;
                    }
                }

                return true;
            }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>Requests the retrieving of an advertisement. This function can only be used 
 /// in 3-legged-mode (To use when the OAuth token has been included in the construction of the client).</summary>
 /// <param name="adSpace">The adSpace of the Bluevia application.</param>
 /// <param name="country">Optional: country where the target user is located.
 /// Must follow <a href="http://www.iso.org/iso/country_codes.htm)">ISO-3166</a>.</param>
 /// <param name="adRequestId">Optional: an unique id for the request. 
 /// (if it is not set, the SDK will generate it automatically).</param>
 /// <param name="adPresentation">Optional: The value is a code that represents the ad format type</param>
 /// <param name="keywords">Optional: If you wish to retrieve advertisings related to some keywords.</param>
 /// <param name="protectionPolicy">Optional: The adult control policy. It will be safe, low, high. 
 /// It should be checked with the application SLA in the Bluevia endpoint</param>
 /// <param name="userAgent">Optional: The user agent of the client. ("none" by default).</param>
 /// <returns>The result returned by the server that contains the advertising meta-data</returns>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public new Schemas.SimpleAdResponse GetAdvertising3L(string adSpace, string country = null
     , string adRequestId = null, TypeId adPresentation = 0, string[] keywords = null
     , ProtectionPolicy protectionPolicy = 0, string userAgent = "none")
 {
     return base.GetAdvertising3L(adSpace, country, adRequestId, adPresentation, keywords, protectionPolicy, userAgent);
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>As this function can only be used in 3-legged-mode, this function checks that,
        /// and if needed, generates the apropiate identifier. Then calls <see cref="GetAdvertisingProcess"/>
        /// </summary>
        /// <param name="adSpace">The adSpace of the Bluevia application.</param>
        /// <param name="country">Country where the target user is located.
        /// Must follow <a href="http://www.iso.org/iso/country_codes.htm)">ISO-3166</a>.</param>
        /// <param name="adRequestId">An unique id for the request. 
        /// (if it is not set, the SDK will generate it automatically).</param>
        /// <param name="adPresentation">The value is a code that represents the ad format type</param>
        /// <param name="keywords">If you wish to retrieve advertisings related to some keywords.</param>
        /// <param name="protectionPolicy">The adult control policy. It will be <a href=""> safe, low, high.</a> 
        /// It should be checked with the application SLA in the Bluevia endpoint</param>
        /// <param name="userAgent">The user agent of the client. ("none" by default).</param>
        /// <returns>The result returned by the server that contains the advertising meta-data</returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        protected SimpleAdResponse GetAdvertising3L(string adSpace, string country
            , string adRequestId, TypeId adPresentation, string[] keywords
            , ProtectionPolicy protectionPolicy, string userAgent)
        {
            if (connector.IsTwoLegged())
            {
                throw new BlueviaException("GetAdvertising is only for requesting advertising by threelegged mode."
                           , ExceptionCode.InvalidModeException);
            }
            //RequestId is mandatory for the request, so if the developer hasnt specified it, a new one is created
            //with token
            if (string.IsNullOrEmpty(adRequestId))
            {
                adRequestId = string.Concat(connector.GetToken(), Convert.ToString(DateTime.UtcNow));
            }

            return GetAdvertisingProcess(adSpace, country, null
            , adRequestId, adPresentation, keywords
            , protectionPolicy, userAgent, null);
        }
Example #21
0
        public ASdu(BinaryReader reader, ConnectionSettings settings, int aSduLength)
        {
            int typeIdCode = reader.ReadByte();

            typeId = (TypeId) typeIdCode;

            int tempbyte = reader.ReadByte();

            IsSequenceOfElements = (tempbyte & 0x80) == 0x80;

            int numberOfSequenceElements;
            int numberOfInformationObjects;

            sequenceLength = tempbyte & 0x7f;
            if (IsSequenceOfElements)
            {
                numberOfSequenceElements = sequenceLength;
                numberOfInformationObjects = 1;
            }
            else
            {
                numberOfInformationObjects = sequenceLength;
                numberOfSequenceElements = 1;
            }

            tempbyte = reader.ReadByte();
            causeOfTransmission = (CauseOfTransmission) (tempbyte & 0x3f);
            test = (tempbyte & 0x80) == 0x80;
            negativeConfirm = (tempbyte & 0x40) == 0x40;

            if (settings.CotFieldLength == 2)
            {
                originatorAddress = reader.ReadByte();
                aSduLength--;
            }
            else
            {
                originatorAddress = -1;
            }

            if (settings.CommonAddressFieldLength == 1)
            {
                commonAddress = reader.ReadByte();
            }
            else
            {
                commonAddress = reader.ReadByte() + (reader.ReadByte() << 8);
                aSduLength--;
            }

            if (typeIdCode < 128)
            {
                informationObjects = new InformationObject[numberOfInformationObjects];

                for (var i = 0; i < numberOfInformationObjects; i++)
                {
                    informationObjects[i] = new InformationObject(reader, typeId, numberOfSequenceElements, settings);
                }

                privateInformation = null;
            }
            else
            {
                informationObjects = null;
                privateInformation = reader.ReadBytes(aSduLength - 4);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary> This function creates and calls the advertising request, with the data received from
        /// <see cref="GetAdvertising2L"/> and <see cref="GetAdvertising3L"/>.</summary>
        /// <param name="adSpace">The adSpace of the Bluevia application.</param>
        /// <param name="country">Country where the target user is located.
        /// Must follow <a href="http://www.iso.org/iso/country_codes.htm)">ISO-3166</a>.</param>
        /// <param name="targetUserId">Identifier of the Target User.</param> 
        /// <param name="adRequestId">An unique id for the request.  
        /// (if it is not set, the SDK will generate it automatically).</param>
        /// <param name="adPresentation">The value is a code that represents the ad format type</param>
        /// <param name="keywords">If you wish to retrieve advertisings related to some keywords.</param>
        /// <param name="protectionPolicy">The adult control policy. It will be <a href=""> safe, low, high.</a> 
        /// It should be checked with the application SLA in the Bluevia endpoint</param>
        /// <param name="userAgent">The user agent of the client. ("none" by default).</param>
        /// <param name="xPhoneNumber">Will be used to convey the MSISDN to whom the advertising is targeted in trusted behavior.</param>
        /// <returns>The result returned by the server that contains the ad meta-data</returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        private SimpleAdResponse GetAdvertisingProcess(string adSpace, string country, string targetUserId
            , string adRequestId, TypeId adPresentation, string[] keywords
            , ProtectionPolicy protectionPolicy, string userAgent, string xPhoneNumber)
        {
            if (string.IsNullOrEmpty(adSpace))
            {
                throw new BlueviaException("Null or empty adSpace when getting Advertising."
                        , ExceptionCode.InvalidArgumentException);
            }

            //Building the request object
            SimpleAdRequest simpleAdRequest = AdvertisingTools.CreateSimpleAdRequest(adSpace, country, targetUserId, adRequestId, adPresentation, keywords, protectionPolicy, userAgent);

            Dictionary<string,string> headers = CreateHeaders(HttpTools.ContetTypeFormUrl);
            if(!string.IsNullOrEmpty(xPhoneNumber))
            {
                headers.Add(Constants.XPhoneKey,xPhoneNumber);
            }

            //Dont need to select the apropiate parser/serializer for the operation:

            //The Bluevia´s complex response object, as result of the call:
            SimpleAdResponseType simpleAdResponseType = BaseCreate<SimpleAdResponseType, Dictionary<string, string>>(
                string.Format(url, Constants.AdvertisingAdRequestSend)
                ,CreateParameters()
                ,simpleAdRequest.ToDictionary()
                , headers);

            return AdvertisingSimplifiers.SimplifyAdResponse(simpleAdResponseType);
        }
        /// <summary>
        ///     項目変更前の処理 - 閣僚type
        /// </summary>
        /// <param name="control">idのコントロール</param>
        /// <param name="val">編集項目の値</param>
        /// <param name="settings">国家設定</param>
        /// <param name="typeId">typeとidの組</param>
        private void PreItemChangedCabinetType(TextBox control, object val, CountrySettings settings, TypeId typeId)
        {
            // 新規idを設定する
            typeId.Id = Scenarios.GetNewId((int) val, 1);

            // 編集済みフラグを設定する
            ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag;
            SetItemDirty(itemId, settings);

            // 編集項目の値を更新する
            UpdateItemValue(control, settings);

            // 編集項目の色を更新する
            UpdateItemColor(control, settings);
        }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>As this function can only be used in 2-legged-mode, this function checks that,
 /// and if needed, generates the apropiate identifier. Then calls <see cref="GetAdvertisingProcess"/>
 /// </summary>
 /// <param name="adSpace">The adSpace of the Bluevia application.</param>
 /// <param name="country">Country where the target user is located.
 /// Must follow <a href="http://www.iso.org/iso/country_codes.htm)">ISO-3166</a>.</param>
 /// <param name="targetUserId">Identifier of the Target User.</param> 
 /// <param name="adRequestId">An unique id for the request.  
 /// (if it is not set, the SDK will generate it automatically).</param>
 /// <param name="adPresentation">The value is a code that represents the ad format type</param>
 /// <param name="keywords">If you wish to retrieve advertisings related to some keywords.</param>
 /// <param name="protectionPolicy">The adult control policy. It will be <a href=""> safe, low, high.</a> 
 /// It should be checked with the application SLA in the Bluevia endpoint</param>
 /// <param name="userAgent">The user agent of the client. ("none" by default).</param>
 /// <param name="xPhoneNumber">Will be used to convey the MSISDN to whom the advertising is targeted in trusted behavior.</param>
 /// <returns>The result returned by the server that contains the ad meta-data</returns>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 protected SimpleAdResponse GetAdvertising2L(string adSpace, string country ,string targetUserId
     , string adRequestId, TypeId adPresentation, string[] keywords
     , ProtectionPolicy protectionPolicy, string userAgent, string xPhoneNumber)
 {
     if(!connector.IsTwoLegged())
     {
         throw new BlueviaException("GetAdvertising2L is only for requesting advertising by twolegged mode."
                    , ExceptionCode.InvalidModeException);
     }
     if (string.IsNullOrEmpty(xPhoneNumber))
     {
         if (string.IsNullOrEmpty(country))
         {
             throw new BlueviaException("Null or empty \"country\" when calling GetAdvertising2L."
                     , ExceptionCode.InvalidArgumentException);
         }
     }
     //RequestId is mandatory for the request, so if the developer hasn't specified it, a new one is created
     //without token
     if (string.IsNullOrEmpty(adRequestId))
     {
         adRequestId = string.Concat(
             Guid.NewGuid().ToString().Replace("-", "_")
             , Convert.ToString(DateTime.UtcNow));
     }
     return GetAdvertisingProcess(adSpace,country,targetUserId
     ,adRequestId,adPresentation,keywords
     ,protectionPolicy,userAgent,xPhoneNumber);
 }
Example #25
0
		public object Invoke(string mungedName, string signature, Type returnType, bool refArgs, params object[] args) {
#if DEBUG
			if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
				Console.WriteLine(	"ENTER SmokeInvocation.Invoke() MethodName: {0}.{1} Type: {2} ArgCount: {3}", 
									className,
									signature, 
									returnType, 
									args.Length / 2 );
			}
#endif

			if (signature.StartsWith("operator==")) {
				if (args[1] == null && args[3] == null)
					return true;
				else if (args[1] == null || args[3] == null)
					return false;
			}
			ModuleIndex methodId;
			methodId.smoke = IntPtr.Zero;
			methodId.index = -1;
			if (!methodIdCache.TryGetValue(signature, out methodId)) {
				methodId = FindMethodId(className, mungedName, signature);

				if (methodId.index == -1) {
					Console.Error.WriteLine(	"LEAVE Invoke() ** Missing method ** {0}.{1}", 
												className,
												signature );
					return null;
				}

				methodIdCache[signature] = methodId;
			}

			StackItem[] stack = new StackItem[(args.Length / 2) + 1];
			TypeId[] typeIDs = new TypeId[(args.Length / 2) + 1];

			unsafe {
				fixed(StackItem * stackPtr = stack) {
					fixed (TypeId * typeIDsPtr = typeIDs) {
						typeIDs[0] = 0;
						for (int i = 1, k = 1; i < args.Length; i += 2, k++) {
							typeIDs[k] = SmokeMarshallers.UnboxToStackItem(args[i], stackPtr + k);
						}

						object returnValue = null;

						if (instance == null) {
							CallSmokeMethod(methodId.smoke, (int) methodId.index, (IntPtr) 0, (IntPtr) stackPtr, args.Length / 2, (IntPtr) typeIDsPtr);
						} else {
#if DEBUG
							GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
#else
							GCHandle instanceHandle = GCHandle.Alloc(instance);
#endif
							CallSmokeMethod(methodId.smoke, methodId.index, (IntPtr) instanceHandle, (IntPtr) stackPtr, args.Length / 2, (IntPtr) typeIDsPtr);
#if DEBUG
							DebugGCHandle.Free(instanceHandle);
#else
							instanceHandle.Free();
#endif
						}
					
						if (returnType != typeof(void)) {
							returnValue = SmokeMarshallers.BoxFromStackItem(returnType, (int) typeIDs[0], stackPtr);
						}

						if (refArgs) {
							for (int i = 1, k = 1; i < args.Length; i += 2, k++) {
								Type t = args[i].GetType();
								if (t.IsPrimitive || t == typeof(NativeLong) || t == typeof(NativeULong)) {
									args[i] = SmokeMarshallers.BoxFromStackItem(args[i].GetType(), (int) typeIDs[k], stackPtr + k);
								}
							}
						}

						return returnValue;
					}
				}
			}
		}
        /// <summary>
        /// Returns an object describing the type of the named signal element
        /// </summary>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="elementType">Type of the element.</param>
        /// <returns>
        /// Type definition corresponding to the signal element name or null if not found
        /// </returns>
        private TypeDefinition GetElementType(string elementName, TypeId elementType)
        {
            // First look in the collection of known types
            lock (m_TypeDefinitionsByName)
            {
                var types = from type in m_TypeDefinitionsByName[elementName]
                            where type.TypeId == elementType
                            select type;
                if (types.Count() == 1)
                {
                    return types.First();
                }
            }

            XElement typeNode = FindTypeNode(elementName, s_TypeIdsToXmlTags[elementType]);
            TypeDefinition typeDefinition = null;
            if (typeNode != null)
            {
                typeDefinition = TypeDefinition.Create(this, typeNode);
                if (typeDefinition.Ref.HasValue)
                {
                    lock (m_TypeDefinitionsByRefId)
                    {
                        m_TypeDefinitionsByRefId[typeDefinition.Ref.Value] = typeDefinition;
                    }
                }

                lock (m_TypeDefinitionsByName)
                {
                    m_TypeDefinitionsByName.Add(typeDefinition.Name, typeDefinition);
                }

                // Now that a placeholder for this type has been added to the two dictionaries it's safe to
                // complete the construction even if there's a recursive reference back to this item
                typeDefinition.FinishConstruction(typeNode, this);
            }

            return typeDefinition;
        }
 public static string GetEmittedName(TypeId id)
 {
     return emittedNames[(int)id];
 }
Example #28
0
        public InformationObject(BinaryReader reader, TypeId typeId, int numberOfSequenceElements,
            ConnectionSettings settings)
        {
            if (settings.IoaFieldLength == 1)
            {
                informationObjectAddress = reader.ReadByte();
            }
            else if (settings.IoaFieldLength == 2)
            {
                informationObjectAddress = reader.ReadByte() + (reader.ReadByte() << 8);
            }
            else if (settings.IoaFieldLength == 3)
            {
                informationObjectAddress = reader.ReadByte() + (reader.ReadByte() << 8) + (reader.ReadByte() << 16);
            }

            switch (typeId)
            {
                // 1
                case TypeId.M_SP_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[1];
                        informationElements[i][0] = new IeSinglePointWithQuality(reader);
                    }
                    break;
                // 2
                case TypeId.M_SP_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeSinglePointWithQuality(reader), new IeTime24(reader)}};
                    break;
                // 3
                case TypeId.M_DP_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[1];
                        informationElements[i][0] = new IeDoublePointWithQuality(reader);
                    }
                    break;
                // 4
                case TypeId.M_DP_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeDoublePointWithQuality(reader), new IeTime24(reader)}};
                    break;
                // 5
                case TypeId.M_ST_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[2];
                        informationElements[i][0] = new IeValueWithTransientState(reader);
                        informationElements[i][1] = new IeQuality(reader);
                    }
                    break;
                // 6
                case TypeId.M_ST_TA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeValueWithTransientState(reader), new IeQuality(reader), new IeTime24(reader)}
                    };
                    break;
                // 7
                case TypeId.M_BO_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[2];
                        informationElements[i][0] = new IeBinaryStateInformation(reader);
                        informationElements[i][1] = new IeQuality(reader);
                    }
                    break;
                // 8
                case TypeId.M_BO_TA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeBinaryStateInformation(reader), new IeQuality(reader), new IeTime24(reader)}
                    };
                    break;
                // 9
                case TypeId.M_ME_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[2];
                        informationElements[i][0] = new IeNormalizedValue(reader);
                        informationElements[i][1] = new IeQuality(reader);
                    }
                    break;
                // 10
                case TypeId.M_ME_TA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeNormalizedValue(reader), new IeQuality(reader), new IeTime24(reader)}
                    };
                    break;
                // 11
                case TypeId.M_ME_NB_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[2];
                        informationElements[i][0] = new IeScaledValue(reader);
                        informationElements[i][1] = new IeQuality(reader);
                    }
                    break;
                // 12
                case TypeId.M_ME_TB_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeScaledValue(reader), new IeQuality(reader), new IeTime24(reader)}};
                    break;
                // 13
                case TypeId.M_ME_NC_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[2];
                        informationElements[i][0] = new IeShortFloat(reader);
                        informationElements[i][1] = new IeQuality(reader);
                    }
                    break;
                // 14
                case TypeId.M_ME_TC_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeShortFloat(reader), new IeQuality(reader), new IeTime24(reader)}};
                    break;
                // 15
                case TypeId.M_IT_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[1];
                        informationElements[i][0] = new IeBinaryCounterReading(reader);
                    }
                    break;
                // 16
                case TypeId.M_IT_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeBinaryCounterReading(reader), new IeTime24(reader)}};
                    break;
                // 17
                case TypeId.M_EP_TA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeSingleProtectionEvent(reader), new IeTime16(reader), new IeTime24(reader)}
                    };
                    break;
                // 18
                case TypeId.M_EP_TB_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeProtectionStartEvent(reader),
                            new IeProtectionQuality(reader), new IeTime16(reader), new IeTime24(reader)
                        }
                    };
                    break;
                // 19
                case TypeId.M_EP_TC_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeProtectionOutputCircuitInformation(reader),
                            new IeProtectionQuality(reader), new IeTime16(reader), new IeTime24(reader)
                        }
                    };
                    break;
                // 20
                case TypeId.M_PS_NA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[2];
                        informationElements[i][0] = new IeStatusAndStatusChanges(reader);
                        informationElements[i][1] = new IeQuality(reader);
                    }
                    break;
                // 21
                case TypeId.M_ME_ND_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[1];
                        informationElements[i][0] = new IeNormalizedValue(reader);
                    }
                    break;
                // 30
                case TypeId.M_SP_TB_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeSinglePointWithQuality(reader), new IeTime56(reader)}};
                    break;
                // 31
                case TypeId.M_DP_TB_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeDoublePointWithQuality(reader), new IeTime56(reader)}};
                    break;
                // 32
                case TypeId.M_ST_TB_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeValueWithTransientState(reader), new IeQuality(reader), new IeTime56(reader)}
                    };
                    break;
                // 33
                case TypeId.M_BO_TB_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeBinaryStateInformation(reader), new IeQuality(reader), new IeTime56(reader)}
                    };
                    break;
                // 34
                case TypeId.M_ME_TD_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeNormalizedValue(reader), new IeQuality(reader), new IeTime56(reader)}
                    };
                    break;
                // 35
                case TypeId.M_ME_TE_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeScaledValue(reader), new IeQuality(reader), new IeTime56(reader)}};
                    break;
                // 36
                case TypeId.M_ME_TF_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeShortFloat(reader), new IeQuality(reader), new IeTime56(reader)}};
                    break;
                // 37
                case TypeId.M_IT_TB_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeBinaryCounterReading(reader), new IeTime56(reader)}};
                    break;
                // 38
                case TypeId.M_EP_TD_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {new IeSingleProtectionEvent(reader), new IeTime16(reader), new IeTime56(reader)}
                    };
                    break;
                // 39
                case TypeId.M_EP_TE_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeProtectionStartEvent(reader),
                            new IeProtectionQuality(reader), new IeTime16(reader), new IeTime56(reader)
                        }
                    };
                    break;
                // 40
                case TypeId.M_EP_TF_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeProtectionOutputCircuitInformation(reader),
                            new IeProtectionQuality(reader), new IeTime16(reader), new IeTime56(reader)
                        }
                    };
                    break;
                // 45
                case TypeId.C_SC_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeSingleCommand(reader)}};
                    break;
                // 46
                case TypeId.C_DC_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeDoubleCommand(reader)}};
                    break;
                // 47
                case TypeId.C_RC_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeRegulatingStepCommand(reader)}};
                    break;
                // 48
                case TypeId.C_SE_NA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeNormalizedValue(reader), new IeQualifierOfSetPointCommand(reader)}};
                    break;
                // 49
                case TypeId.C_SE_NB_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeScaledValue(reader), new IeQualifierOfSetPointCommand(reader)}};
                    break;
                // 50
                case TypeId.C_SE_NC_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeShortFloat(reader), new IeQualifierOfSetPointCommand(reader)}};
                    break;
                // 51
                case TypeId.C_BO_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeBinaryStateInformation(reader)}};
                    break;
                // 58
                case TypeId.C_SC_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeSingleCommand(reader), new IeTime56(reader)}};
                    break;
                // 59
                case TypeId.C_DC_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeDoubleCommand(reader), new IeTime56(reader)}};
                    break;
                // 60
                case TypeId.C_RC_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeBinaryStateInformation(reader), new IeTime56(reader)}};
                    break;
                // 61
                case TypeId.C_SE_TA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNormalizedValue(reader),
                            new IeQualifierOfSetPointCommand(reader), new IeTime56(reader)
                        }
                    };
                    break;
                // 62
                case TypeId.C_SE_TB_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeScaledValue(reader),
                            new IeQualifierOfSetPointCommand(reader), new IeTime56(reader)
                        }
                    };
                    break;
                // 63
                case TypeId.C_SE_TC_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeShortFloat(reader),
                            new IeQualifierOfSetPointCommand(reader), new IeTime56(reader)
                        }
                    };
                    break;
                // 64
                case TypeId.C_BO_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeBinaryStateInformation(reader), new IeTime56(reader)}};
                    break;
                // 70
                case TypeId.M_EI_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeCauseOfInitialization(reader)}};
                    break;
                // 100
                case TypeId.C_IC_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeQualifierOfInterrogation(reader)}};
                    break;
                // 101
                case TypeId.C_CI_NA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeQualifierOfCounterInterrogation(reader)}};
                    break;
                // 102
                case TypeId.C_RD_NA_1:
                    informationElements = new InformationElement[0][];
                    break;
                // 103
                case TypeId.C_CS_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeTime56(reader)}};
                    break;
                // 104
                case TypeId.C_TS_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeFixedTestBitPattern(reader)}};
                    break;
                // 105
                case TypeId.C_RP_NA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeQualifierOfResetProcessCommand(reader)}};
                    break;
                // 106
                case TypeId.C_CD_NA_1:
                    informationElements = new[] {new InformationElement[] {new IeTime16(reader)}};
                    break;
                // 107
                case TypeId.C_TS_TA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeTestSequenceCounter(reader), new IeTime56(reader)}};
                    break;
                // 110
                case TypeId.P_ME_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNormalizedValue(reader),
                            new IeQualifierOfParameterOfMeasuredValues(reader)
                        }
                    };
                    break;
                // 111
                case TypeId.P_ME_NB_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeScaledValue(reader),
                            new IeQualifierOfParameterOfMeasuredValues(reader)
                        }
                    };
                    break;
                // 112
                case TypeId.P_ME_NC_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeShortFloat(reader),
                            new IeQualifierOfParameterOfMeasuredValues(reader)
                        }
                    };
                    break;
                // 113
                case TypeId.P_AC_NA_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeQualifierOfParameterActivation(reader)}};
                    break;
                // 120
                case TypeId.F_FR_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNameOfFile(reader), new IeLengthOfFileOrSection(reader),
                            new IeFileReadyQualifier(reader)
                        }
                    };
                    break;
                // 121
                case TypeId.F_SR_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNameOfFile(reader), new IeNameOfSection(reader),
                            new IeLengthOfFileOrSection(reader), new IeSectionReadyQualifier(reader)
                        }
                    };
                    break;
                // 122
                case TypeId.F_SC_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNameOfFile(reader), new IeNameOfSection(reader),
                            new IeSelectAndCallQualifier(reader)
                        }
                    };
                    break;
                // 123
                case TypeId.F_LS_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNameOfFile(reader), new IeNameOfSection(reader),
                            new IeLastSectionOrSegmentQualifier(reader), new IeChecksum(reader)
                        }
                    };
                    break;
                // 124
                case TypeId.F_AF_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNameOfFile(reader), new IeNameOfSection(reader),
                            new IeAckFileOrSectionQualifier(reader)
                        }
                    };
                    break;
                // 125
                case TypeId.F_SG_NA_1:
                    informationElements = new[]
                    {
                        new InformationElement[]
                        {
                            new IeNameOfFile(reader), new IeNameOfSection(reader),
                            new IeFileSegment(reader)
                        }
                    };
                    break;
                // 126
                case TypeId.F_DR_TA_1:
                    informationElements = new InformationElement[numberOfSequenceElements][];
                    for (var i = 0; i < numberOfSequenceElements; i++)
                    {
                        informationElements[i] = new InformationElement[4];
                        informationElements[i][0] = new IeNameOfFile(reader);
                        informationElements[i][1] = new IeLengthOfFileOrSection(reader);
                        informationElements[i][2] = new IeStatusOfFile(reader);
                        informationElements[i][3] = new IeTime56(reader);
                    }
                    break;
                // 127
                case TypeId.F_SC_NB_1:
                    informationElements = new[]
                    {new InformationElement[] {new IeNameOfFile(reader), new IeTime56(reader), new IeTime56(reader)}};
                    break;
                default:
                    throw new IOException(
                        "Unable to parse Information Object because of unknown Type Identification: " + typeId);
            }
        }
        ShapeData ConstructAndAddShape(TypeId typeId)
        {
            UIElement element;

            if (typeId == TypeId.Line) {
                var line = new Line {StrokeEndLineCap = PenLineCap.Round};
                element = line;
            }
            else if (typeId == TypeId.Text) {
                element = new TextBlock ();
            }
            else if (typeId == TypeId.Oval) {
                element = new Ellipse ();
            }
            else if (typeId == TypeId.Arc) {
                element = new Path();
            }
            else if (typeId == TypeId.RoundedRect) {
                element = new Rectangle ();
            }
            else if (typeId == TypeId.Rect) {
                element = new Rectangle ();
            }
            else if (typeId == TypeId.Image) {
                element = new Image ();
            }
            else if (typeId == TypeId.Polygon) {
                element = new NativePolygon ();
            }
            else {
                throw new NotSupportedException ("Don't know how to construct: " + typeId);
            }

            var sd = new ShapeData {
                Element = element,
                TypeId = typeId,
            };

            _shapes.Add (sd);

            //
            // Insert it in the right place so it gets drawn in the right order
            //
            if (_lastAddElementIndex >= 0) {
                _lastAddElementIndex++;
                _canvas.Children.Insert(_lastAddElementIndex, element);
            }
            else {
                if (_lastShape != null) {
                    _lastAddElementIndex = _canvas.Children.IndexOf(_lastShape.Element) + 1;
                    _canvas.Children.Insert(_lastAddElementIndex, element);
                }
                else {
                    _lastAddElementIndex = _canvas.Children.Count;
                    _canvas.Children.Add(element);
                }
            }

            return sd;
        }
Example #30
0
        /// <summary>
        ///     typeとidの組を登録する
        /// </summary>
        /// <param name="id">typeとidの組</param>
        /// <returns>登録に成功すればtrueを返す</returns>
        public static bool AddTypeId(TypeId id)
        {
            if (id == null)
            {
                return false;
            }

            if (!_usedTypeIds.ContainsKey(id.Type))
            {
                _usedTypeIds.Add(id.Type, new HashSet<int>());
            }

            if (_usedTypeIds[id.Type].Contains(id.Id))
            {
                return false;
            }
            _usedTypeIds[id.Type].Add(id.Id);

            return true;
        }