private MapField MappingMapFieldModelToMapField(MapFieldModel mfm)
        {
            MapField mapField = new MapField();
            mapField.FieldId = mfm.FieldId;
            mapField.MapId = mfm.MapId;

            return mapField;
        }
Beispiel #2
0
 public EventMove(
     IAudioEngine s,
     EventManager m,
     int id,
     NSMap.Character.EventMove[] mo,
     SceneMap ma,
     MapField fi,
     SaveData save)
     : base(s, m, save)
 {
     this.NoTimeNext = true;
     this.ID         = id;
     this.moves      = mo;
     this.map        = ma;
     this.field      = fi;
 }
Beispiel #3
0
 public RunEvent(
     IAudioEngine s,
     EventManager m,
     string ID,
     int p,
     SceneMap map,
     MapField fi,
     SaveData save)
     : base(s, m, save)
 {
     this.NoTimeNext   = false;
     this.eventID      = ID;
     this.page         = p - 1;
     this.field        = fi;
     this.eventmanager = new EventManager(map, this.sound);
 }
Beispiel #4
0
        public int MovieId;                    //动画Id

        public EncourageActRuleVo(EncourageActRulePB encourageActRulePb)
        {
            Id              = encourageActRulePb.Id;
            Title           = encourageActRulePb.Title;
            NeedTime        = encourageActRulePb.NeedTime;
            Fans            = encourageActRulePb.Fans;
            Consume         = encourageActRulePb.Consume;
            Awards          = encourageActRulePb.Awards;
            Power           = encourageActRulePb.Power;
            DepartmentLevel = encourageActRulePb.DepartmentLevel;
            Pro             = encourageActRulePb.Pro;
            ActType         = encourageActRulePb.ActType;
            Order           = encourageActRulePb.Order;
            RandomFansNum   = encourageActRulePb.RandomeFansNum;
            MovieId         = encourageActRulePb.MovieId;
        }
Beispiel #5
0
        public void Capability_Handled_Correctly(string value)
        {
            MapField <string, string> addedCapabilities = new MapField <string, string>
            {
                { testCapability2, value }
            };

            _capabilities.UpdateCapabilities(addedCapabilities);

            Assert.Equal(value, _capabilities.GetCapabilityState(testCapability2));

            var logs = _loggerProvider.GetAllLogMessages().Select(p => p.FormattedMessage).ToArray();

            Assert.Collection(logs,
                              p => Assert.Equal($"Updating capabilities: {{ \"{testCapability2}\": \"{value}\" }}", p));
        }
        public void ContainsNoDurableClientNameIfBindingNameIsEmpty()
        {
            var bindings = new MapField <string, BindingInfo>
            {
                {
                    string.Empty,
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.In, Type = "durableClient"
                    }
                }
            };

            var durableFunctionInfo = DurableFunctionInfoFactory.Create(bindings);

            Assert.False(durableFunctionInfo.IsDurableClient);
            Assert.Null(durableFunctionInfo.DurableClientBindingName);
        }
Beispiel #7
0
 public MysteryItem(
     IAudioEngine s,
     EventManager m,
     MapField field,
     RandomMystery item,
     bool message,
     MysteryData mystery,
     SaveData save)
     : base(s, m, save)
 {
     this.field      = field;
     this.mystery    = mystery;
     this.itemData   = item;
     this.message    = message;
     this.NoTimeNext = message;
     this.parent     = m.parent;
 }
Beispiel #8
0
        private MapField Closest(IEnumerable <MapField> listFields)
        {
            MapField closestField = null;
            float    minDist      = float.PositiveInfinity;

            foreach (MapField field in listFields)
            {
                float cur = MapField.Distance(Location, field);
                if (cur < minDist)
                {
                    minDist      = cur;
                    closestField = field;
                }
            }

            return(closestField);
        }
        public void ContainsDurableClientName()
        {
            var bindings = new MapField <string, BindingInfo>
            {
                {
                    "TestBindingName",
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.In, Type = "durableClient"
                    }
                }
            };

            var durableFunctionInfo = DurableFunctionInfoFactory.Create(bindings);

            Assert.True(durableFunctionInfo.IsDurableClient);
            Assert.Equal("TestBindingName", durableFunctionInfo.DurableClientBindingName);
        }
        private static void ValidateMap(MapField mf, object value)
        {
            if (!value.GetType().TryExtractEnumerableType(out Type elementType))
            {
                throw new ArgumentException($"map must be a collection, but found {value.GetType()}");
            }

            if (elementType != typeof(Row))
            {
                throw new ArgumentException($"map element must be a collection of rows, but found a collection of {elementType}");
            }

            foreach (Row row in (IEnumerable)value)
            {
                Validate(row, new[] { mf.Key, mf.Value });
            }
        }
Beispiel #11
0
            public PrositIntensityOutput(MapField <string, TensorProto> prositOutput)
            {
                var outputTensor = prositOutput[OUTPUT_KEY];

                // Note that this is essentially a lightweight iterator. We pass
                // down an index by reference that keeps getting increased.
                var precursorCount = outputTensor.TensorShape.Dim[0].Size;

                OutputRows = new PrositPrecursorOutput[precursorCount];
                var index = 0;

                // Copy intensities for each precursor
                for (var i = 0; i < precursorCount; ++i)
                {
                    OutputRows[i] = new PrositPrecursorOutput(outputTensor, ref index);
                }
            }
Beispiel #12
0
 /// <summary>
 /// Execute callbacks in future callback collection
 /// </summary>
 /// <param name="tid">tid</param>
 /// <param name="code">rpc status code</param>
 /// <param name="text">text</param>
 /// <param name="paramaters">paramaters</param>
 public void ExecFuture(string tid, int code, string text, MapField <string, ByteString> paramaters)
 {
     if (onCompletion.ContainsKey(tid))
     {
         var bundle = onCompletion[tid];
         onCompletion.Remove(tid);
         if (code >= 200 && code < 400)
         {
             var arg = bundle.Arg;
             bundle.Action(arg, paramaters);
         }
         else
         {
             Console.WriteLine($"Error:{code}, {text}");
         }
     }
 }
Beispiel #13
0
        /// <summary>
        /// Funkcja wywoływana przez zdazrenie puszczenia klawisza myszy
        /// </summary>
        /// <param name="sender">obiekt wysylajacy zdarzenie</param>
        /// <param name="e">argumenty zdarzenia</param>
        public override void Window_MouseButtonReleased(object sender, MouseButtonEventArgs e)
        {
            base.Window_MouseButtonReleased(sender, e);

            if (IsSelected && e.Button == Mouse.Button.Right)
            {
                MapField mapField = Program.map[0, 0];

                int X = (int)(e.X + mapField.ScreenPosition.X) / MapField.ScreenSize,
                    Y = (int)(e.Y + mapField.ScreenPosition.Y) / MapField.ScreenSize;

                if (Program.map[X, Y].ConstructOn != null)
                {
                    Job = Program.map[X, Y].ConstructOn.BuildJob;
                }
            }
        }
Beispiel #14
0
 public MysteryData(
     IAudioEngine s,
     SceneMap p,
     Point po,
     int floor,
     MapCharacterBase.ANGLE a,
     MapField fi,
     string id,
     SaveData save,
     StreamReader reader,
     RandomMystery random)
     : base(s, p, po, floor, a, fi, id, save, reader, "")
 {
     this.position.Z = this.field.Height / 2 * floor;
     this.itemData   = random;
     this.getInfo    = this.itemData.getInfo;
     this.Update();
 }
        public EventMapField(EventMapConverter <TKey, TValue> converter, MapField <TKey, TValue> mapField, bool isMessageType = false)
        {
            _converter     = converter;
            _isMessageType = isMessageType;

            if (_isMessageType)
            {
                _internal = new MapField <TKey, TValue>();
                foreach (var kv in mapField)
                {
                    InternalAdd(kv.Key, kv.Value);
                }
            }
            else
            {
                _internal = mapField;
            }
        }
Beispiel #16
0
 public EffectMake(
     IAudioEngine s,
     EventManager m,
     int effectNumber,
     string ID,
     int X,
     int Y,
     int Z,
     int nORv,
     int interval,
     int randomXY,
     int rendType,
     string SE,
     SceneMap parent,
     MapField field,
     MapEventBase event_,
     SaveData save)
     : base(s, m, save)
 {
     this.NoTimeNext   = true;
     this.effectNumber = effectNumber;
     this.Z            = Z;
     this.X            = X;
     this.Y            = Y;
     if (event_ != null)
     {
         this.event_ = event_;
     }
     this.nORv     = nORv;
     this.field    = field;
     this.parent   = parent;
     this.ID       = ID;
     this.interval = interval;
     this.randomXY = randomXY;
     this.rendType = rendType;
     try
     {
         this.SE = (SoundEffect)Enum.Parse(typeof(SoundEffect), SE);
     }
     catch
     {
         this.SE = SoundEffect.none;
     }
 }
        /// <summary>
        /// Executes the task asynchronously.
        /// </summary>
        /// <param name="command">The command, e.g "call".</param>
        /// <param name="parameters">The specified parameters.</param>
        /// <returns>The executed task.</returns>
        public override Task ExecuteAsync(string command, MapField <string, Value> parameters)
        {
            switch (command)
            {
            case "WriteMessage":
                parameters.TryGetValue("message", out Value message);
                this.SendSMS(ContactManager.GetPersonNumber(parameters), message.ToString());
                break;

            case "help":
                this.SendSMS(this.User.MainCarerPhoneNumber, $"{this.User.FirstName} {this.User.LastName} braucht Hilfe!");
                break;

            default:
                break;
            }

            return(Task.CompletedTask);
        }
Beispiel #18
0
        public MapField <int, int> Apparel;  //用户服饰
        public UserFavorabilityVo(UserFavorabilityPB pb)
        {
            UserId = pb.UserId;
            Player = pb.Player;
            Level  = pb.Level;
            if (pb.Level > 1)
            {
                Exp = GlobalData.FavorabilityMainModel.GetCurExp(pb.Exp, pb.Level);
            }
            else
            {
                Exp = pb.Exp;
            }

            Apparel = pb.Apparel;

            ShowExp   = pb.Exp;
            VoiceKeep = pb.VoiceKeep;
        }
Beispiel #19
0
    public bool IsShowRedDot = false; //红点



    public ReloadingVO(DressUpUnlockRulePB pB)
    {
        ItemId      = pB.ItemId;
        ItemType    = pB.ItemType;
        Player      = pB.Player;
        MoneyClaim  = pB.MoneyClaim;
        ClothesGoal = pB.ClothesGoal;
        UnlockDesc  = pB.UnlockDesc;

        BgImages = new List <string> {
            pB.MornImage, pB.NoonImage, pB.AfternoonImage
        };

        InitIsGet();
        InitIconPath();
        InitName();
        InitWeight();
        SetRedDot();
    }
Beispiel #20
0
 public MapChange(
     IAudioEngine s,
     EventManager m,
     string name,
     Point po,
     int f,
     MapCharacterBase.ANGLE a,
     SaveData save,
     MapField field)
     : base(s, m, save)
 {
     field.parent.parent.MapTextureAdd(name);
     field.parent.parent.MapTextureAdd(save.pluginMap);
     this.NoTimeNext = true;
     this.mapName    = name;
     this.position   = po;
     this.floor      = f;
     this.angle      = a;
 }
        internal AzFunctionInfo(RpcFunctionMetadata metadata)
        {
            FunctionName = metadata.Name;
            Directory    = metadata.Directory;
            EntryPoint   = metadata.EntryPoint;
            ScriptPath   = metadata.ScriptFile;

            AllBindings    = new MapField <string, BindingInfo>();
            OutputBindings = new MapField <string, BindingInfo>();

            foreach (var binding in metadata.Bindings)
            {
                string      bindingName = binding.Key;
                BindingInfo bindingInfo = binding.Value;

                AllBindings.Add(bindingName, bindingInfo);

                // PowerShell doesn't support the 'InOut' type binding
                if (bindingInfo.Direction == BindingInfo.Types.Direction.In)
                {
                    switch (bindingInfo.Type)
                    {
                    case OrchestrationTrigger:
                        Type = AzFunctionType.OrchestrationFunction;
                        break;

                    case ActivityTrigger:
                        Type = AzFunctionType.ActivityFunction;
                        break;

                    default:
                        Type = AzFunctionType.RegularFunction;
                        break;
                    }
                    continue;
                }

                if (bindingInfo.Direction == BindingInfo.Types.Direction.Out)
                {
                    OutputBindings.Add(bindingName, bindingInfo);
                }
            }
        }
Beispiel #22
0
        private static DurableFunctionType GetDurableFunctionType(MapField <string, BindingInfo> bindings)
        {
            var inputBindings = bindings.Where(binding => binding.Value.Direction == BindingInfo.Types.Direction.In);

            foreach (var(_, value) in inputBindings)
            {
                if (DurableBindings.IsOrchestrationTrigger(value.Type))
                {
                    return(DurableFunctionType.OrchestrationFunction);
                }

                if (DurableBindings.IsActivityTrigger(value.Type))
                {
                    return(DurableFunctionType.ActivityFunction);
                }
            }

            return(DurableFunctionType.None);
        }
Beispiel #23
0
        public Cards(IEnumerable <SabberStoneCore.Model.Card> allCards)
        {
            cards_ = new MapField <int, Card>();

            foreach (var card in allCards)
            {
                if (card.Name == null)
                {
                    continue;
                }

                cards_.Add(card.AssetId, new Card
                {
                    Id       = card.AssetId,
                    Name     = card.Name,
                    StringId = card.Id
                });
            }
        }
Beispiel #24
0
        public override void CreateThrift(Field field, Thrift.SchemaElement parent, IList <Thrift.SchemaElement> container)
        {
            parent.Num_children += 1;

            //add the root container where map begins
            var root = new Thrift.SchemaElement(field.Name)
            {
                Converted_type  = Thrift.ConvertedType.MAP,
                Num_children    = 1,
                Repetition_type = Thrift.FieldRepetitionType.OPTIONAL
            };

            container.Add(root);

            //key-value is a container for column of keys and column of values
            var keyValue = new Thrift.SchemaElement(MapField.ContainerName)
            {
                Num_children    = 0, //is assigned by children
                Repetition_type = Thrift.FieldRepetitionType.REPEATED
            };

            container.Add(keyValue);

            //now add the key and value separately
            MapField         mapField     = field as MapField;
            IDataTypeHandler keyHandler   = DataTypeFactory.Match(mapField.Key);
            IDataTypeHandler valueHandler = DataTypeFactory.Match(mapField.Value);

            keyHandler.CreateThrift(mapField.Key, keyValue, container);
            Thrift.SchemaElement tseKey = container[container.Count - 1];
            valueHandler.CreateThrift(mapField.Value, keyValue, container);
            Thrift.SchemaElement tseValue = container[container.Count - 1];

            //fixups for weirdness in RLs
            if (tseKey.Repetition_type == Thrift.FieldRepetitionType.REPEATED)
            {
                tseKey.Repetition_type = Thrift.FieldRepetitionType.OPTIONAL;
            }
            if (tseValue.Repetition_type == Thrift.FieldRepetitionType.REPEATED)
            {
                tseValue.Repetition_type = Thrift.FieldRepetitionType.OPTIONAL;
            }
        }
        // Take the data from a two-dimensional array and build a table at the
        // end of the supplied document.
        public static Table GetGenericPropertyTable(WordprocessingDocument document, string col1Name, string col2Name,
                                                    MapField <string, string> data, string styleName = "GridTable4-Accent1")
        {
            var table = new Table();

            var tr  = new TableRow();
            var tch = new TableCell();

            tch.Append(new Paragraph(new Run(new Text(col1Name))));
            var width = new TableCellWidth();

            width.Type  = TableWidthUnitValues.Pct;
            width.Width = "30";
            tch.Append(new TableCellProperties(
                           width));
            var tch2 = new TableCell();

            tch2.Append(new Paragraph(new Run(new Text(col2Name))));
            var element = new TableCellWidth();

            element.Type  = TableWidthUnitValues.Pct;
            element.Width = "70";
            tch2.Append(new TableCellProperties(
                            element));
            tr.Append(tch);
            tr.Append(tch2);
            table.Append(tr);
            foreach (var r in data)
            {
                var trr = new TableRow();
                var tc  = new TableCell();
                tc.Append(new Paragraph(new Run(new Text(r.Key))));
                var tc2 = new TableCell();
                tc2.Append(new Paragraph(new Run(new Text(r.Value))));

                trr.Append(tc);
                trr.Append(tc2);
                table.Append(trr);
            }
            ApplyStyleTable(document, styleName, styleName, table);
            return(table);
        }
        /// <summary>
        /// Gets the persons number from the specified contact.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The extracted phone number.</returns>
        public static string GetPersonNumber(MapField <string, Value> parameters)
        {
            var uri        = ContactsContract.CommonDataKinds.Phone.ContentUri;
            var projection = new string[]
            {
                ContactsContract.Contacts.InterfaceConsts.Id,
                ContactsContract.CommonDataKinds.Phone.Number,
                ContactsContract.Contacts.InterfaceConsts.DisplayName
            };
            var cursor = Application.Context.ContentResolver.Query(uri, projection, null, null, null);

            string name;

            parameters.TryGetValue("firstname", out Value firstname);
            parameters.TryGetValue("lastname", out Value lastname);

            if (string.IsNullOrWhiteSpace(lastname.StringValue))
            {
                name = firstname.StringValue;
            }
            else
            {
                name = string.Concat(firstname.StringValue, " ", lastname.StringValue);
            }


            if (cursor.MoveToNext())
            {
                do
                {
                    var number      = cursor.GetString(cursor.GetColumnIndex(projection[1]));
                    var displayName = cursor.GetString(cursor.GetColumnIndex(projection[2]));

                    if (displayName == name)
                    {
                        return(number);
                    }
                }while (cursor.MoveToNext());
            }

            return(string.Empty);
        }
Beispiel #27
0
        private async Task <FileWeightsReply> GetFileWeightsInternal(GetFileWeightsRequest request)
        {
            var reply = new FileWeightsReply();

            if (string.IsNullOrWhiteSpace(request.RootName))
            {
                reply.Error = Error.NoSuchEntity;
                return(reply);
            }
            var path   = PathSep + request.RootName;
            var folder = await _service.All().Where(k => k.Name == request.RootName && k.Path == path && k.Type == (int)FileType.Folder)
                         .FirstOrDefaultAsync();

            if (folder == null)
            {
                reply.Error = Error.NoSuchEntity;
                return(reply);
            }
            var pathStart = folder.Path + PathSep;
            var weights   = await _service.All().Where(p => p.Type == (int)FileType.Normal && p.Path.StartsWith(pathStart)).Select(f => new { f.Name, f.Weight })
                            .ToArrayAsync();

            foreach (var w in weights)
            {
                reply.Weights.Add(w.Name.ToString(), w.Weight ?? 0);
            }
            var codec = new MapField <string, int> .Codec(FieldCodec.ForString(0), FieldCodec.ForInt32(1), 0);

            var version = await _contentService.Add(_cachesGroup, fs =>
            {
                using (var s = new CodedOutputStream(fs))
                {
                    reply.WriteTo(s);
                }

                return(Task.FromResult(true));
            }, "bin");

            await _cache.SetStringAsync(FileWeightsVersionCacheKey(request.RootName), version);

            return(reply);
        }
Beispiel #28
0
        /// <summary>
        /// Creates the customization.
        /// </summary>
        /// <returns>The customization.</returns>
        /// <param name="logo">Logo.</param>
        /// <param name="colors">map of ARGB colors #AARRGGBB.</param>
        /// <param name="consentText">Consent text.</param>
        /// <param name="name">Display Name.</param>
        /// <param name="appName">Corresponding App name.</param>
        public Task <string> CreateCustomization(
            Payload logo,
            MapField <string, string> colors,
            string consentText,
            string name,
            string appName)
        {
            var request = new CreateCustomizationRequest
            {
                Logo        = logo,
                Colors      = { colors },
                Name        = name,
                ConsentText = consentText,
                AppName     = appName
            };

            return(gateway(authenticationContext())
                   .CreateCustomizationAsync(request)
                   .ToTask(response => response.CustomizationId));
        }
        public async Task ToRpc_Bytes_With_Capabilities_Value()
        {
            var logger       = MockNullLoggerFactory.CreateLogger();
            var capabilities = new Capabilities(logger);
            MapField <string, string> addedCapabilities = new MapField <string, string>
            {
                { RpcWorkerConstants.TypedDataCollection, RpcWorkerConstants.TypedDataCollection }
            };

            capabilities.UpdateCapabilities(addedCapabilities);
            byte[] arrByte = Encoding.Default.GetBytes("HellowWorld");

            TypedData returned_typedata = await arrByte.ToRpc(logger, capabilities);

            TypedData typedData = new TypedData();

            typedData.Bytes = ByteString.CopyFrom(arrByte);

            Assert.Equal(typedData.Bytes, returned_typedata.Bytes);
        }
Beispiel #30
0
    void RegisterObstacle()
    {
        MapField mapField = GameRoot.GetInstance().MapField;

        for (int i = 0; i < col; ++i)
        {
            for (int j = 0; j < row; ++j)
            {
                int value = mapGrids[i, j];
                if (value == -1)
                {
                    mapField.CreateStructure(i + 1, j + 1, 1, 6);
                }
                else if (value > 0 && value < 20)
                {
                    mapField.CreateStructure(i + 1, j + 1, 1, 6);
                }
            }
        }
    }
        public void ContainsFirstInputDurableClientName()
        {
            var bindings = new MapField <string, BindingInfo>
            {
                {
                    "Binding1",
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.In, Type = "anotherBindingType"
                    }
                },
                {
                    "Binding2",
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.Out, Type = "durableClient"
                    }
                },
                {
                    "Binding3",
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.Inout, Type = "durableClient"
                    }
                },
                {
                    "Binding4",
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.In, Type = "durableClient"
                    }
                },
                {
                    "Binding5",
                    new BindingInfo {
                        Direction = BindingInfo.Types.Direction.In, Type = "yetAnotherBindingType"
                    }
                }
            };

            var durableFunctionInfo = DurableFunctionInfoFactory.Create(bindings);

            Assert.True(durableFunctionInfo.IsDurableClient);
            Assert.Equal("Binding4", durableFunctionInfo.DurableClientBindingName);
        }
 static int GetFieldLength(TextWriter writer, MapField field)
 {
     switch(field.Type)
     {
         case FieldType.BOOL:
         case FieldType.U8:
         case FieldType.S8:
             return 1;
         case FieldType.U16:
         case FieldType.S16:
         case FieldType.IPPORT:
             return 2;
         case FieldType.U32:
         case FieldType.S32:
         case FieldType.F32:
         case FieldType.IPADDR:
             return 4;
         case FieldType.U64:
         case FieldType.F64:
             return 8;
         case FieldType.LLVector3:
         case FieldType.LLQuaternion:
             return 12;
         case FieldType.LLUUID:
         case FieldType.LLVector4:
         //case FieldType.LLQuaternion:
             return 16;
         case FieldType.LLVector3d:
             return 24;
         case FieldType.Fixed:
             return field.Count;
         case FieldType.Variable:
             return 0;
         default:
             writer.WriteLine("!!! ERROR: Unhandled FieldType " + field.Type.ToString() + " !!!");
             return 0;
     }
 }
Beispiel #33
0
 static void WriteFieldFromBytes(TextWriter writer, MapField field)
 {
     switch (field.Type)
     {
         case FieldType.BOOL:
             writer.WriteLine("                    " +
                 field.Name + " = (bytes[i++] != 0) ? (bool)true : (bool)false;");
             break;
         case FieldType.F32:
             writer.WriteLine("                    " + 
                 "if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4);");
             writer.WriteLine("                    " +
                 field.Name + " = BitConverter.ToSingle(bytes, i); i += 4;");
             break;
         case FieldType.F64:
             writer.WriteLine("                    " +
                 "if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8);");
             writer.WriteLine("                    " +
                 field.Name + " = BitConverter.ToDouble(bytes, i); i += 8;");
             break;
         case FieldType.Fixed:
             writer.WriteLine("                    " + field.Name + " = new byte[" + field.Count + "];");
             writer.WriteLine("                    Buffer.BlockCopy(bytes, i, " + field.Name +
                 ", 0, " + field.Count + "); i += " + field.Count + ";");
             break;
         case FieldType.IPADDR:
         case FieldType.U32:
             writer.WriteLine("                    " + field.Name + 
                 " = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));");
             break;
         case FieldType.IPPORT:
             // IPPORT is big endian while U16/S16 are little endian. Go figure
             writer.WriteLine("                    " + field.Name +
                 " = (ushort)((bytes[i++] << 8) + bytes[i++]);");
             break;
         case FieldType.U16:
             writer.WriteLine("                    " + field.Name + 
                 " = (ushort)(bytes[i++] + (bytes[i++] << 8));");
             break;
         case FieldType.LLQuaternion:
             writer.WriteLine("                    " + field.Name +
                 " = new LLQuaternion(bytes, i, true); i += 12;");
             break;
         case FieldType.LLUUID:
             writer.WriteLine("                    " + field.Name +
                 " = new LLUUID(bytes, i); i += 16;");
             break;
         case FieldType.LLVector3:
             writer.WriteLine("                    " + field.Name +
                 " = new LLVector3(bytes, i); i += 12;");
             break;
         case FieldType.LLVector3d:
             writer.WriteLine("                    " + field.Name +
                 " = new LLVector3d(bytes, i); i += 24;");
             break;
         case FieldType.LLVector4:
             writer.WriteLine("                    " + field.Name +
                 " = new LLVector4(bytes, i); i += 16;");
             break;
         case FieldType.S16:
             writer.WriteLine("                    " + field.Name +
                 " = (short)(bytes[i++] + (bytes[i++] << 8));");
             break;
         case FieldType.S32:
             writer.WriteLine("                    " + field.Name +
                 " = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));");
             break;
         case FieldType.S8:
             writer.WriteLine("                    " + field.Name +
                 " = (sbyte)bytes[i++];");
             break;
         case FieldType.U64:
             writer.WriteLine("                    " + field.Name +
                 " = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + " +
                 "((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + " +
                 "((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + " +
                 "((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56));");
             break;
         case FieldType.U8:
             writer.WriteLine("                    " + field.Name +
                 " = (byte)bytes[i++];");
             break;
         case FieldType.Variable:
             if (field.Count == 1)
             {
                 writer.WriteLine("                    length = (ushort)bytes[i++];");
             }
             else
             {
                 writer.WriteLine("                    length = (ushort)(bytes[i++] + (bytes[i++] << 8));");
             }
             writer.WriteLine("                    _" + field.Name.ToLower() + " = new byte[length];");
             writer.WriteLine("                    Buffer.BlockCopy(bytes, i, _" + field.Name.ToLower() +
                 ", 0, length); i += length;");
             break;
         default:
             writer.WriteLine("!!! ERROR: Unhandled FieldType: " + field.Type.ToString() + " !!!");
             break;
     }
 }
Beispiel #34
0
        static void WriteFieldMember(TextWriter writer, MapField field)
        {
            string type = String.Empty;

            switch (field.Type)
            {
                case FieldType.BOOL:
                    type = "bool";
                    break;
                case FieldType.F32:
                    type = "float";
                    break;
                case FieldType.F64:
                    type = "double";
                    break;
                case FieldType.IPPORT:
                case FieldType.U16:
                    type = "ushort";
                    break;
                case FieldType.IPADDR:
                case FieldType.U32:
                    type = "uint";
                    break;
                case FieldType.LLQuaternion:
                    type = "LLQuaternion";
                    break;
                case FieldType.LLUUID:
                    type = "LLUUID";
                    break;
                case FieldType.LLVector3:
                    type = "LLVector3";
                    break;
                case FieldType.LLVector3d:
                    type = "LLVector3d";
                    break;
                case FieldType.LLVector4:
                    type = "LLVector4";
                    break;
                case FieldType.S16:
                    type = "short";
                    break;
                case FieldType.S32:
                    type = "int";
                    break;
                case FieldType.S8:
                    type = "sbyte";
                    break;
                case FieldType.U64:
                    type = "ulong";
                    break;
                case FieldType.U8:
                    type = "byte";
                    break;
                case FieldType.Fixed:
                    type = "byte[]";
                    break;
            }
            if (field.Type != FieldType.Variable)
            {
                //writer.WriteLine("            /// <summary>" + field.Name + " field</summary>");
                writer.WriteLine("            public " + type + " " + field.Name + ";");
            }
            else
            {
                writer.WriteLine("            private byte[] _" + field.Name.ToLower() + ";");
                //writer.WriteLine("            /// <summary>" + field.Name + " field</summary>");
                writer.WriteLine("            public byte[] " + field.Name + Environment.NewLine + "            {");
                writer.WriteLine("                get { return _" + field.Name.ToLower() + "; }");
                writer.WriteLine("                set" + Environment.NewLine + "                {");
                writer.WriteLine("                    if (value == null) { _" + 
                    field.Name.ToLower() + " = null; return; }");
                writer.WriteLine("                    if (value.Length > " + 
                    ((field.Count == 1) ? "255" : "1500") + ") { throw new OverflowException(" + 
                    "\"Value exceeds " + ((field.Count == 1) ? "255" : "1500") + " characters\"); }");
                writer.WriteLine("                    else { _" + field.Name.ToLower() +
                    " = new byte[value.Length]; Buffer.BlockCopy(value, 0, _" + 
                    field.Name.ToLower() + ", 0, value.Length); }");
                writer.WriteLine("                }" + Environment.NewLine + "            }");
            }
        }
Beispiel #35
0
        static void WriteFieldToBytes(TextWriter writer, MapField field)
        {
            writer.Write("                ");

            switch (field.Type)
            {
                case FieldType.BOOL:
                    writer.WriteLine("bytes[i++] = (byte)((" + field.Name + ") ? 1 : 0);");
                    break;
                case FieldType.F32:
                    writer.WriteLine("ba = BitConverter.GetBytes(" + field.Name + ");" + Environment.NewLine +
                        "                if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); }" + Environment.NewLine +
                        "                Buffer.BlockCopy(ba, 0, bytes, i, 4); i += 4;");
                    break;
                case FieldType.F64:
                    writer.WriteLine("ba = BitConverter.GetBytes(" + field.Name + ");" + Environment.NewLine +
                        "                if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); }" + Environment.NewLine +
                        "                Buffer.BlockCopy(ba, 0, bytes, i, 8); i += 8;");
                    break;
                case FieldType.Fixed:
                    writer.WriteLine("                Buffer.BlockCopy(" + field.Name + ", 0, bytes, i, " + field.Count + ");" + 
                        "i += " + field.Count + ";");
                    break;
                case FieldType.IPPORT:
                    // IPPORT is big endian while U16/S16 is little endian. Go figure
                    writer.WriteLine("bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)(" + field.Name + " % 256);");
                    break;
                case FieldType.U16:
                case FieldType.S16:
                    writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);");
                    break;
                case FieldType.LLUUID:
                    writer.WriteLine("Buffer.BlockCopy(" + field.Name + ".GetBytes(), 0, bytes, i, 16); i += 16;");
                    break;
                case FieldType.LLVector4:
                    writer.WriteLine("Buffer.BlockCopy(" + field.Name + ".GetBytes(), 0, bytes, i, 16); i += 16;");
                    break;
                case FieldType.LLQuaternion:
                case FieldType.LLVector3:
                    writer.WriteLine("Buffer.BlockCopy(" + field.Name + ".GetBytes(), 0, bytes, i, 12); i += 12;");
                    break;
                case FieldType.LLVector3d:
                    writer.WriteLine("Buffer.BlockCopy(" + field.Name + ".GetBytes(), 0, bytes, i, 24); i += 24;");
                    break;
                case FieldType.U8:
                    writer.WriteLine("bytes[i++] = " + field.Name + ";");
                    break;
                case FieldType.S8:
                    writer.WriteLine("bytes[i++] = (byte)" + field.Name + ";");
                    break;
                case FieldType.IPADDR:
                case FieldType.U32:
                case FieldType.S32:
                    writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 16) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 24) % 256);");
                    break;
                case FieldType.U64:
                    writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 16) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 24) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 32) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 40) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 48) % 256);");
                    writer.WriteLine("                bytes[i++] = (byte)((" + field.Name + " >> 56) % 256);");
                    break;
                case FieldType.Variable:
                    writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }");
                    writer.Write("                ");
                    if (field.Count == 1)
                    {
                        writer.WriteLine("bytes[i++] = (byte)" + field.Name + ".Length;");
                    }
                    else
                    {
                        writer.WriteLine("bytes[i++] = (byte)(" + field.Name + ".Length % 256);");
                        writer.WriteLine("                bytes[i++] = (byte)((" + 
                            field.Name + ".Length >> 8) % 256);");
                    }
                    writer.WriteLine("                Buffer.BlockCopy(" + field.Name + ", 0, bytes, i, " + 
                        field.Name + ".Length); " + "i += " + field.Name + ".Length;");
                    break;
                default:
                    writer.WriteLine("!!! ERROR: Unhandled FieldType: " + field.Type.ToString() + " !!!");
                    break;
            }
        }
 internal RiakDtMapField(MapField mapField)
 {
     Name = mapField.name.FromRiakString();
     Type = (RiakDtMapFieldType)mapField.type;
 }