/// <summary>
        /// Initializes a new instance of the <see cref="MVC_Controller"/> class.
        /// </summary>
        public MVC_Controller(long maxSize, bool isByte, bool isNS, bool isClean, string path)
        {
            this.caretaker = new Caretaker();
            this.cor = new COR();
            this.maxSize = maxSize;
            this.isNS = isNS;
            this.isByte = isByte;
            this.path = path;
            if (isClean)
            {
                cleanStorage();
            }
            else
            {
                try
                {
                    LoadStorage();
                }
                catch
                {
                    Console.WriteLine("Storage file doesn't exist!");
                    Console.WriteLine("Creating a new one...");
                    this.storage = new Storage(maxSize, isByte, isNS, path);
                    SaveStorage();
                }
            }

        }
Beispiel #2
0
        private void Start()
        {
            //this.Hide();

            _timer = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(10);
            _timer.Tick += _timer_Tick;
            _timer.Start();

            _events = new Events();
            _storage = new Storage(_events);
            _trayIcon = new TrayIcon(this);

            _events.OnInvokeDrop += _storage.Drop;
            _events.OnInvokeExpire += _storage.Expire;
            _events.OnInvokePeek += _storage.Peek;
            _events.OnInvokePoke += _storage.Poke;
            _events.OnInvokePinch += _storage.Pinch;
            _events.OnInvokePop += _storage.Pop;
            _events.OnInvokePush += _storage.Push;
            _events.OnInvokeShunt += _storage.Shunt;
            _events.OnInvokeReverse += _storage.Reverse;
            _events.OnInvokeRotateLeft += _storage.RotateLeft;
            _events.OnInvokeRotateRight += _storage.RotateRight;
            _events.OnInvokeSwap += _storage.Swap;
            _events.OnInvokeWipe += _storage.Wipe;
        }
 public BitmapEnumerator(Storage s, int[] bm, int n) 
 { 
     storage = s;
     bitmap = bm;
     n_bits = n;
     curr = -1;
 } 
Beispiel #4
0
    public static Storage LineIntersects2dObject(Vector position, Vector feeler,
										Vector lineCoordA, Vector lineCoordB,
										double distance, Vector pt)
    {
        Storage tmp = new Storage();

        double top = ((position.y() - lineCoordA.y())*(lineCoordB.x() - lineCoordA.x())) -
                     ((position.x() - lineCoordA.x())* (lineCoordB.y()-lineCoordA.y()));
        double bot = ((feeler.x()-position.x())*(lineCoordB.y()-lineCoordA.y())) -
                     ((feeler.y()-position.y())*(lineCoordB.x()-lineCoordA.x()));

        double topTwo = ((position.y() - lineCoordA.y())*(feeler.x() - position.x())) -
                     ((position.x() - lineCoordA.x())* (feeler.y()-position.y()));
        double botTwo = bot;

        if(bot == 0)tmp.wasItTrue = false;
        double r = top / bot;
        double t = topTwo / botTwo;
        if( (r > 0) && (r < 1) && (t > 0) && (t < 1)){
            Vector temp =feeler - position;
            tmp.dist = Mathf.Sqrt((float)temp.lengthSquared());
            pt = position + (temp * r);
            tmp.wasItTrue = true;
        }else {
            tmp.dist = 0;
            tmp.wasItTrue = false;
        }
        return tmp;
    }
 void Start()
 {
     st = transform.root.GetComponent<Storage>();
     pc = GameObject.Find("Player").GetComponent<PlayerController>();
     startPos = transform.position;
     startScale = transform.localScale;
 }
 /// <summary>
 /// AssocDB constructor. You should open and close storage yourself. You are free to set some storage properties, 
 /// storage listener and use some other storage administrative methods  like backup.
 /// But you should <b>not</b>: <ol>
 /// <li>specify your own root object for the storage</li>
 /// <li>use Storage commit or rollback methods directly</li>
 /// <li>modify storage using Perst classes not belonging to this package</li>
 /// </ol>
 /// </summary>
 /// <param name="storage">opened Perst storage</param>
 public AssocDB(Storage storage)
 {
     this.storage = storage;
     storage.SetProperty("perst.concurrent.iterator", true);
     embeddedRelationThreshold = DEFAULT_EMBEDDED_RELATION_THRESHOLD;
     language = DEFAULT_DOCUMENT_LANGUAGE;
     root = (Root)storage.Root;
     name2id = new Dictionary<string, int>();
     id2name = new Dictionary<int, string>();
     if (root == null)
     {
         root = CreateRoot();
         storage.Root = root;
         storage.Commit();
     }
     else
     {
         root.db = this;
         IDictionaryEnumerator e = root.attributes.GetDictionaryEnumerator();
         while (e.MoveNext())
         {
             int id = ((IPersistent)e.Value).Oid;
             String name = (String)e.Key;
             name2id[name] = id;
             id2name[id] = name;
         }
     }
 }
 private SqlBuffer(SqlBuffer value)
 {
     this._isNull = value._isNull;
     this._type = value._type;
     this._value = value._value;
     this._object = value._object;
 }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Showes process results with details in message window.
        /// </summary>
        /// <param name="importer">Importer object.</param>
        /// <param name="geocoder">Geocoder object (can be NULL).</param>
        /// <param name="storage">Storage object</param>
        /// <param name="status">Status text.</param>
        public void Inform(Importer importer, Geocoder geocoder, Storage storage, string status)
        {
            Debug.Assert(!string.IsNullOrEmpty(status)); // not empty
            Debug.Assert(null != importer); // created
            Debug.Assert(null != storage); // created

            var details = new List<MessageDetail>();

            // add statistic
            string statistic = _CreateStatistic(importer, geocoder, storage);
            Debug.Assert(!string.IsNullOrEmpty(statistic));
            var statisticDetail = new MessageDetail(MessageType.Information, statistic);
            details.Add(statisticDetail);

            // add geocoder exception
            if ((null != geocoder) &&
                (null != geocoder.Exception))
            {
                details.Add(_GetServiceMessage(geocoder.Exception));
            }

            // add steps deatils
            details.AddRange(importer.Details);
            if (null != geocoder)
                details.AddRange(geocoder.Details);
            details.AddRange(storage.Details);

            // show status with details
            App.Current.Messenger.AddMessage(status, details);
        }
        public void Write(Storage storage, string fileSpecificPath, string fileWordsPath)
        {
            var bitmap = new List<byte>();

            var words = GenerateWordsStringAndBitmap(bitmap, storage);
            if (words == null || words == "")
                return;
            var bytemap = new List<byte>();

            while (bitmap.Count > 0)
            {
                var oneByte = bitmap.Take(8).ToList();
                bitmap = bitmap.Skip(8).ToList();
                bytemap.Add(oneByte.Aggregate((byte)0, (result, bit) => (byte)((result << 1) | bit)));
            }

            using (var streamWriter = new StreamWriter(fileWordsPath))
            {
                streamWriter.Write(words);
            }
            using (var fileStream = new FileStream(fileSpecificPath, FileMode.OpenOrCreate))
            {
                fileStream.Write(bytemap.ToArray(), 0, bytemap.Count);
                fileStream.Close();
            }
        }
        public static async Task CreateNewCatalog(Storage storage, IDictionary<string, IList<JObject>> packages, CancellationToken cancellationToken)
        {
            IList<KeyValuePair<string, IList<JObject>>> batch = new List<KeyValuePair<string, IList<JObject>>>();

            IList<JObject> catalogPages = new List<JObject>();

            int packageCount = 0;

            foreach (KeyValuePair<string, IList<JObject>> item in packages)
            {
                batch.Add(item);

                packageCount += item.Value.Count;

                if (packageCount >= 100)
                {
                    packageCount = 0;

                    catalogPages.Add(MakeCatalogPage(batch));
                    batch.Clear();
                }
            }

            if (batch.Count > 0)
            {
                catalogPages.Add(MakeCatalogPage(batch));
            }

            JObject catalogIndex = MakeCatalogIndex(storage, catalogPages);

            await Save(storage, catalogIndex, catalogPages, cancellationToken);
        }
Beispiel #11
0
    static void Main(string[] args)
    {
        int L = int.Parse(Console.ReadLine());
        int H = int.Parse(Console.ReadLine());
        int RL = L * 27;
        string T = Console.ReadLine();
        Storage storage = new Storage(L, H);
        for (int i = 0; i < H; i++)
        {
            string ROW = Console.ReadLine();
            int offset = 0;
            if (ROW.Length == RL)
                for (int j = 0; j < 27; j++)
                {
                    string str = ROW.Substring(offset, L);
                    offset += L;
                    for (int ii = 0; ii < str.Length; ii++)
                        storage[j][i, ii] = str[ii];
                }
        }

        // Write an action using Console.WriteLine()
        // To debug: Console.Error.WriteLine("Debug messages...");
        Console.WriteLine(storage.GetValue(T));
    }
Beispiel #12
0
        public void ArtifactLoader_Unittest() {
            var packageDir = new Storage(ArtifactDir + "/loader");
            var outputDir = new Storage(ArtifactDir + "/.compilation");
            var code = @"
using System;
public class UserWrapper{
    public Yanyitec.SSO.Identity GetIdentity(string name){
        return new Yanyitec.SSO.Identity(Guid.NewGuid(),name);
    } 
}
";
            var name = "TestLoader";
            var projDir = packageDir.GetDirectory("TestLoader", true);
            projDir.PutText("UserWrapper.cs", code);

            var json = "{\"frameworks\":{\"net450\":{\"dependencies\":{\"Yanyitec\":\"\"}}}";
            projDir.PutText("project.json",json);

            var loader = new ArtifactLoader(packageDir, outputDir);
            var artifact = loader.Load(name);
            var type = artifact.Assembly.DefinedTypes.FirstOrDefault(p=>p.Name == "UserWrapper");
            var obj = Activator.CreateInstance(type);
            var methodInfo = type.GetMethods().FirstOrDefault(p=>p.Name== "GetIdentity");
            var result = methodInfo.Invoke(obj, new object[] { "yanyi"});

        }
Beispiel #13
0
 public CopyFileAction(File source, Storage destinationStorage, string destinationPath, string destinationName)
 {
     Source = source;
     DestinationStorage = destinationStorage;
     DestinationPath = destinationPath;
     DestinationName = destinationName;
 }
    public static void Main(String[] args) {
        db = StorageFactory.Instance.CreateStorage();
        if (args.Length > 0) 
        { 
            db.SetProperty("perst.object.cache.kind", args[0]);
        }
	    db.Open("testconcur.dbs");
        L2List list = (L2List)db.Root;
        if (list == null) { 
            list = new L2List();
            list.head = new L2Elem();
            list.head.next = list.head.prev = list.head;
            db.Root = list;
            for (int i = 1; i < nElements; i++) { 
                L2Elem elem = new L2Elem();
                elem.count = i;
                elem.linkAfter(list.head); 
            }
        }
        Thread[] threads = new Thread[nThreads];
        for (int i = 0; i < nThreads; i++) { 
            threads[i] = new Thread(new ThreadStart(run));
            threads[i].Start();
        }
#if !COMPACT_NET_FRAMEWORK
        for (int i = 0; i < nThreads; i++) 
        { 
            threads[i].Join();
        }
        db.Close();
#endif
    }
Beispiel #15
0
 public Data.Node Load(Storage storage, Data.Node data)
 {
     if (data is Data.Collection)
         for (int i = 0; i < (data as Data.Collection).Nodes.Count; i++)
             (data as Data.Collection).Nodes[i] = this.Load(storage, (data as Data.Collection).Nodes[i]);
     else if (data is Data.Branch)
     {
         Kean.Collection.IDictionary<string, Data.Node> nodes = new Kean.Collection.Dictionary<string, Data.Node>((data as Data.Branch).Nodes.Count);
         foreach (Data.Node child in (data as Data.Branch).Nodes)
         {
             Data.Node n = nodes[child.Name];
             if (n.IsNull())
                 nodes[child.Name] = child;
             else if (n is Data.Collection)
                 (n as Data.Collection).Nodes.Add(child.UpdateLocators((string)child.Locator + "[" + (n as Data.Collection).Nodes.Count + "]"));
             else
             {
                 Data.Collection collection = new Data.Collection() { Name = child.Name, Locator = child.Locator, Region = child.Region }; // TODO: include all children in region
                 collection.Nodes.Add(n.UpdateLocators((string)n.Locator + "[0]"));
                 collection.Nodes.Add(child.UpdateLocators((string)child.Locator + "[1]"));
                 nodes[child.Name] = collection;
             }
         }
         (data as Data.Branch).Nodes.Clear();
         foreach (KeyValue<string, Data.Node> n in nodes)
             (data as Data.Branch).Nodes.Add(this.Load(storage, n.Value));
     }
     return data;
 }
Beispiel #16
0
        protected override void OnCreating(object sender, Storage.Events.CancellableNodeEventArgs e)
        {
            base.OnCreating(sender, e);

            var searchPath = e.SourceNode.Parent.GetType().Name == "Survey" ? e.SourceNode.ParentPath : e.SourceNode.Parent.ParentPath;

            // Count Survey Items
            var surveyItemCount = ContentQuery.Query(string.Format("+Type:surveyitem +InTree:\"{0}\" .AUTOFILTERS:OFF .COUNTONLY", searchPath)).Count;

            // Get children (SurveyItems) count
            String tempName;
            if (surveyItemCount < 10 && surveyItemCount != 9)
                tempName = "SurveyItem_0" + (surveyItemCount + 1);
            else
                tempName = "SurveyItem_" + (surveyItemCount + 1);

            // If node already exits
            while (Node.Exists(RepositoryPath.Combine(e.SourceNode.Parent.Path, tempName)))
            {
                surveyItemCount++;
                if (surveyItemCount < 10)
                    tempName = "SurveyItem_0" + (surveyItemCount + 1);
                else
                    tempName = "SurveyItem_" + (surveyItemCount + 1);
            }

            e.SourceNode["DisplayName"] = tempName;
            e.SourceNode["Name"] = tempName.ToLower();
        }
Beispiel #17
0
        public async Task Download(Storage storage, Action<int> downloadProgress, Action<int> writeProgressAction, CancellationToken ct, Stream responseStream)
        {
            using (responseStream)
            {
                try
                {
                    for (;;)
                    {
                        if (!EnoughSpaceInWriteBuffer())
                        {
                            FlushBuffer(storage, writeProgressAction);
                        }

                        var bytesRead = await responseStream.ReadAsync(_writeBuffer, _writeBufferPosition, MaxPortionSize, ct);

                        if (bytesRead == 0)
                        {
                            FlushBuffer(storage, writeProgressAction);
                            break;
                        }

                        MoveReadBufferPosition(bytesRead);
                        downloadProgress(bytesRead);
                    }
                }
                finally 
                {
                    FlushBuffer(storage, writeProgressAction);
                }
            }
        }
Beispiel #18
0
 //contructor
 public Logic()
 {
     UndoList = new List<Storage>();
     if (!OpenQWIKFile())
         QStorage = new Storage();
     LogicInstance = this;
 }
        public Storage Read(string fileSpecificPath, string fileWordsPath)
        {
            Storage storage = null;
            List<int> bits = null;

            var fileInfo = new FileInfo(fileSpecificPath);
            using(var fileStream = new FileStream(fileSpecificPath, FileMode.Open))
            {
                var bytes = new byte[fileInfo.Length];
                fileStream.Read(bytes, 0, (int)fileInfo.Length);
                bits = bytes.SelectMany(GetBits).ToList();
            }

            if (bits == null || bits.Count == 0)
                return null;

            storage = new Storage();

            using (var stream = new StreamReader(fileWordsPath))
            {
                for (int i = 0; i < bits.Count && !stream.EndOfStream; ++i)
                {
                    var line = stream.ReadLine();
                    var pair = line.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);

                    var category = bits[i] == 1 ? "spam" : "ham";
                    if (!storage.Words.ContainsKey(pair[0]))
                        storage.Words.Add(pair[0], new Dictionary<string, int> { { category, int.Parse(pair[1]) } });
                    else
                        storage.Words[pair[0]].Add(category, int.Parse(pair[1]));
                }
            }

            return storage;
        }
Beispiel #20
0
        public EStationStore(Storage? storage, string path = default(string))
        {
            ExceptionlessClient.Default.Configuration.ApiKey = "mnPSl8rxo8I4NghVDeLg96OMlGXlfEMSttioT4hc";

            IEstation estation;

            switch (storage)
            {
                case Storage.SqlLite:
                    estation = new EstationSqlLite(path);
                    break;
                case Storage.WebApi:
                    estation = new EstationWebApi(path);
                    break;
                case Storage.Azure:
                    estation = new EstationAzure(path);
                    break;
                default:
                    estation = new EstationSqlServer(path);
                    break;
            }
           
            HumanResource = estation.HumanResource;
            Authentication = estation.Authentication;
            Economat = estation.Economat;
            Documents = estation.Documents;
            Oils = estation.Oils;
            Meta = estation.Meta;
            Sales = estation.Sales;
            Citernes = estation.Citernes;
            Fuels = estation.Fuels;
            Pompes = estation.Pompes;
            Customers = estation.Customers;
        }
		public StressBenchmark(Storage storage, BenchmarkOptions options)
		{
			this.storage = storage;
			this.readDelayInSeconds = TimeSpan.FromSeconds(5);
			this.statistics = new Statistics(readDelayInSeconds);
			this.options = options;
		}
Beispiel #22
0
 public void Open(Storage storage, JabberUser selectedJabberUser)
 {
     this.mStorage = storage;
     ResetHTML();
     loadArchiveUsersList(selectedJabberUser);
     tbxSearchText.Focus();
 }
Beispiel #23
0
    /// <summary>
    /// Execute the indentation
    /// </summary>
    /// <param name="code">the original code to indent</param>
    /// <returns>the indented code</returns>
    

    //Performs indentation to the inputted code
    public string indent(string code)
    {
      NullIndentor list = new NullIndentor();
      List<string> lis = new List<string>();
      lis = list.convertToList(code);      
      List<string> fileList = new List<string>();
      Storage container = new Storage();
      Layers layer = new Layers();
      foreach (string line in lis)
      {
        Regex r = new Regex(@"\s+");         // regular expression which removes extra spaces
        string lin = r.Replace(line, @" ");  //and replaces it with single space
        CharEnumerator Cnum = lin.GetEnumerator();
        CharEnumerator Cnum2 = (CharEnumerator)Cnum.Clone();
        CommentTokenizer CommentTok = new CommentTokenizer();
        string s = CommentTok.CommentRemover(Cnum);
        if (s == null)
        {
          StringTokenizer Stok = new StringTokenizer();
          Stok.stringtok(Cnum2);
        }
      }      
      file = container.getContainer1();      
      fileList = layer.setList(file);
      code = null;
      foreach (string line in fileList)
      {
        code += line;
      }
      return code;
    }
Beispiel #24
0
        public DirectoryNode GetDirectoryNodeFromStorage(Storage storage)
        {
            try
            {
                var st = storage.References[0];
                //st.
                var eee = storage.References.Clone();
            }
            catch (Exception)
            {

            }

            return  new DirectoryNode(storage.ToString())
                                          {
                                              _audiofile = storage.isAudioFile(),
                                              _canplay = storage.isPlayable(),
                                              _datafile = storage.isDataFile(),
                                              _defaultlocation = storage.isDefault(),
                                              _folder = storage.isFolder(),
                                              _hidden = storage.isHidden(),
                                              _link = storage.isLink(),
                                              _system = storage.isSystem(),
                                              _virtualfile = storage.isVirtual()
                                          };
        }
Beispiel #25
0
 public void Open(Storage storage, JabberUser selectedJabberUser)
 {
     this.mStorage = storage;
     wbConversation.DocumentText = "<HTML><BODY></BODY></HTML>";
     loadArchiveUsersList(selectedJabberUser.JID);
     tbxSearchText.Focus();
 }
Beispiel #26
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Snazzy exception dialog
            Current.DispatcherUnhandledException += (o, args) =>
            {
                MetroException.Show(args.Exception);

                args.Handled = true;
            };

            // Create Assembly Storage
            MetroIdeStorage = new Storage();

            // Create jumplist
            JumpLists.UpdateJumplists();

            // Set closing method
            Current.Exit += (o, args) =>
            {
                // Update Settings with Window Width/Height
                MetroIdeStorage.MetroIdeSettings.ApplicationSizeMaximize =
                    (MetroIdeStorage.MetroIdeSettings.HomeWindow.WindowState == WindowState.Maximized);
                if (MetroIdeStorage.MetroIdeSettings.ApplicationSizeMaximize) return;

                MetroIdeStorage.MetroIdeSettings.ApplicationSizeWidth =
                    MetroIdeStorage.MetroIdeSettings.HomeWindow.Width;
                MetroIdeStorage.MetroIdeSettings.ApplicationSizeHeight =
                    MetroIdeStorage.MetroIdeSettings.HomeWindow.Height;
            };
        }
Beispiel #27
0
 public static void Serialize(Storage s)
 {
     String json = s.ToJSON();
     TextWriter sw = new StreamWriter(Helper.GetApplicationPath() + "/Storage.xml");
     sw.Write(json);
     sw.Close();
 }
Beispiel #28
0
    static void Main(String[] arguments)
    {
        var blobAddress = "http://127.0.0.1:10000/devstoreaccount1/";

        String sas = null;
        using (var sasClient = new SignatureServiceClient())
        {
            Console.Write("User: "******"Password: "******"Sas = " + sas);

        var storage = new Storage(blobAddress, new StorageCredentialsSharedAccessSignature(sas));
        new CommandStore().Execute(storage, arguments);
    }
        public SettingsPage()
        {
            this.InitializeComponent();

            Storage storage = new Storage();

            string sDataKey = "userDetails";
            string uDataKey = "usernameDetails";
            string pDataKey = "passwordDetails";

            string userData = storage.LoadSettings(sDataKey);
            string usernameDetails = storage.LoadSettings(uDataKey);
            string passwordDetails = storage.LoadSettings(pDataKey);
            
            if (userData != "Null")
            {

                var viewModel = new UserDataSource(userData, usernameDetails, passwordDetails);

                LoginForm.Visibility = Visibility.Collapsed;
                UserData.Visibility = Visibility.Visible;
                AccountSettingsPanel.Visibility = Visibility.Visible;

                this.DataContext = viewModel;

            }

        }
 private async Task<Uri> SaveNuspec(Storage storage, string id, string version, string nuspec, CancellationToken cancellationToken)
 {
     var relativeAddress = string.Format("{1}/{0}.nuspec", id, version);
     var nuspecUri = new Uri(storage.BaseAddress, relativeAddress);
     await storage.Save(nuspecUri, new StringStorageContent(nuspec, "text/xml", "max-age=120"), cancellationToken);
     return nuspecUri;
 }
Beispiel #31
0
        private void load(LadderInfo ladder, Storage storage)
        {
            this.ladder = ladder;

            RelativeSizeAxes = Axes.Both;

            InternalChildren = new Drawable[]
            {
                new TourneyVideo("schedule")
                {
                    RelativeSizeAxes = Axes.Both,
                    Loop             = true,
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding(100)
                    {
                        Bottom = 50
                    },
                    Children = new Drawable[]
                    {
                        new GridContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            RowDimensions    = new[]
                            {
                                new Dimension(GridSizeMode.AutoSize),
                                new Dimension(),
                            },
                            Content = new[]
                            {
                                new Drawable[]
                                {
                                    new FillFlowContainer
                                    {
                                        AutoSizeAxes = Axes.Both,
                                        Direction    = FillDirection.Vertical,
                                        Children     = new Drawable[]
                                        {
                                            new DrawableTournamentHeaderText(),
                                            new Container
                                            {
                                                Margin = new MarginPadding {
                                                    Top = 40
                                                },
                                                AutoSizeAxes = Axes.Both,
                                                Children     = new Drawable[]
                                                {
                                                    new Box
                                                    {
                                                        Colour = Color4.White,
                                                        Size   = new Vector2(50, 10),
                                                    },
                                                    new TournamentSpriteTextWithBackground("Schedule")
                                                    {
                                                        X     = 60,
                                                        Scale = new Vector2(0.8f)
                                                    }
                                                }
                                            },
                                        }
                                    },
                                },
                                new Drawable[]
                                {
                                    mainContainer = new Container
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                    }
                                }
                            }
                        }
                    }
                },
            };
        }
Beispiel #32
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        Storage storage  = go.AddComponent <Storage>();
        Storage storage2 = go.AddComponent <Storage>();

        storage2.capacityKg = 20000f;
        go.AddOrGet <BuildingComplete>().isManuallyOperated = false;
        go.AddOrGet <LoopingSounds>();
        Prioritizable.AddRef(go);
        //float num = 2426.72f;
        //float num2 = 0.01f;

        GasTank liquidCooledFan = go.AddOrGet <GasTank>();

        //liquidCooledFan.gasStorage = storage;
        liquidCooledFan.gasStorage = storage2;
        //liquidCooledFan.waterKGConsumedPerKJ = 1f / (num * num2);
        //liquidCooledFan.coolingKilowatts = 80f;
        //liquidCooledFan.minCooledTemperature = 290f;
        //liquidCooledFan.minEnvironmentMass = 0.25f;
        //liquidCooledFan.minCoolingRange = new Vector2I(-2, 0);
        //liquidCooledFan.maxCoolingRange = new Vector2I(2, 4);

        /*
         * ManualDeliveryKG manualDeliveryKG = go.AddComponent<ManualDeliveryKG>();
         * manualDeliveryKG.requestedItemTag = new Tag("Water");
         * manualDeliveryKG.capacity = 500f;
         * manualDeliveryKG.refillMass = 50f;
         * manualDeliveryKG.choreTypeIDHash = Db.Get().ChoreTypes.Fetch.IdHash;
         *
         * ElementConsumer elementConsumer = go.AddOrGet<ElementConsumer>();
         * elementConsumer.storeOnConsume = true;
         * elementConsumer.storage = storage;
         * elementConsumer.configuration = ElementConsumer.Configuration.AllGas;
         * elementConsumer.consumptionRadius = 8;
         * elementConsumer.EnableConsumption(true);
         * elementConsumer.sampleCellOffset = new Vector3(0f, 0f);
         * elementConsumer.showDescriptor = false;
         */
        ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType          = ConduitType.Gas;
        conduitConsumer.consumptionRate      = 10f;
        conduitConsumer.capacityKG           = 20000f;
        conduitConsumer.capacityTag          = GameTags.Gas;
        conduitConsumer.forceAlwaysSatisfied = true;
        conduitConsumer.alwaysConsume        = true;
        conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;

        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType = ConduitType.Gas;

        /*
         * LiquidCooledFanWorkable liquidCooledFanWorkable = go.AddOrGet<LiquidCooledFanWorkable>();
         * liquidCooledFanWorkable.SetWorkTime(20f);
         * liquidCooledFanWorkable.overrideAnims = new KAnimFile[1]
         * {
         *      Assets.GetAnim("anim_interacts_liquidfan_kanim")
         * };
         */
    }
 public UserController(Storage storage)
 {
     _storage = storage;
 }
Beispiel #34
0
 /// <summary>
 ///     Force Marten to create a document mapping for the document type
 /// </summary>
 /// <param name="documentType"></param>
 public void RegisterDocumentType(Type documentType)
 {
     Storage.RegisterDocumentType(documentType);
 }
Beispiel #35
0
 public int CountAll()
 {
     return(Storage.CountAll());
 }
Beispiel #36
0
 public IEnumerable <TDoc> GetAll()
 {
     return(Storage.GetAll());
 }
Beispiel #37
0
 public TDoc GetExisting(TKey id)
 {
     return(Storage.GetExisting(id));
 }
Beispiel #38
0
 public bool IsStackRegister(Storage storage)
 {
     throw new NotImplementedException();
 }
Beispiel #39
0
 /**
  * 存储拍卖信息
  */
 private static void _putAuctionInfo(byte[] dressId, AuctionInfo info)
 {
     byte[] auctionInfo = Helper.Serialize(info);
     Storage.Put(Storage.CurrentContext, dressId, auctionInfo);
 }
Beispiel #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ContentXamlProvider"/> class.
 /// </summary>
 public ContentXamlProvider()
 {
     this.service = WaveServices.Storage;
 }
Beispiel #41
0
 /**
  * 用户在拍卖所存储的代币
  */
 public static BigInteger balanceOf(byte[] address)
 {
     //2018/6/5 cwt 修补漏洞
     byte[] keytaddress = new byte[] { 0x11 }.Concat(address);
     return(Storage.Get(Storage.CurrentContext, keytaddress).AsBigInteger());
 }
Beispiel #42
0
 /**
  * 不包含收取的手续费在内,所有用户存在拍卖行中的代币
  */
 public static BigInteger totalExchargeSgas()
 {
     return(Storage.Get(Storage.CurrentContext, "totalExchargeSgas").AsBigInteger());
 }
        public void Replaced_Type_makes_code_readeable()
        {
            var result = Storage.Store(5);

            Assert.AreEqual(result, StoreResult.Ok);
        }
Beispiel #44
0
        /**
         * 从拍卖场购买,将钱划入合约名下,将物品给买家
         */
        public static bool buyOnAuction(byte[] sender, BigInteger dressId)
        {
            if (!Runtime.CheckWitness(sender))
            {
                //没有签名
                return(false);
            }

            object[] objInfo = _getAuctionInfo(dressId.AsByteArray());
            if (objInfo.Length > 0)
            {
                AuctionInfo info  = (AuctionInfo)(object)objInfo;
                byte[]      owner = info.owner;

                var nowtime    = Blockchain.GetHeader(Blockchain.GetHeight()).Timestamp;
                var secondPass = nowtime - info.sellTime;
                //var secondPass = (nowtime - info.sellTime) / 1000;
                //2018/6/5 cwt 修补漏洞
                byte[] keytsender = new byte[] { 0x11 }.Concat(sender);
                byte[] keytowner = new byte[] { 0x11 }.Concat(owner);

                BigInteger senderMoney = Storage.Get(Storage.CurrentContext, keytsender).AsBigInteger();
                BigInteger curBuyPrice = computeCurrentPrice(info.beginPrice, info.endPrice, info.duration, secondPass);
                var        fee         = curBuyPrice * 50 / 1000;
                if (fee < TX_MIN_FEE)
                {
                    fee = TX_MIN_FEE;
                }
                if (curBuyPrice < fee)
                {
                    curBuyPrice = fee;
                }

                if (senderMoney < curBuyPrice)
                {
                    // 钱不够
                    return(false);
                }


                // 转移物品
                object[] args = new object[3] {
                    ExecutionEngine.ExecutingScriptHash, sender, dressId
                };
                bool res = (bool)deleNgcall("transfer_A2P", args);
                if (!res)
                {
                    return(false);
                }

                // 扣钱
                Storage.Put(Storage.CurrentContext, keytsender, senderMoney - curBuyPrice);

                // 扣除手续费
                BigInteger sellPrice = curBuyPrice - fee;
                _subTotal(fee);

                // 钱记在卖家名下
                BigInteger nMoney     = 0;
                byte[]     salerMoney = Storage.Get(Storage.CurrentContext, keytowner);
                if (salerMoney.Length > 0)
                {
                    nMoney = salerMoney.AsBigInteger();
                }
                nMoney = nMoney + sellPrice;
                Storage.Put(Storage.CurrentContext, keytowner, nMoney);

                // 删除拍卖记录
                Storage.Delete(Storage.CurrentContext, dressId.AsByteArray());

                // notify
                BigInteger oid = _add_oid();
                AuctionBuy(oid, sender, dressId, curBuyPrice, fee, nowtime);
                return(true);
            }
            return(false);
        }
 public StorageBackedResourceStore(Storage storage)
 {
     this.storage = storage;
 }
Beispiel #46
0
        private void load(Storage storage)
        {
            InternalChild = contentContainer = new Container
            {
                Masking          = true,
                CornerRadius     = 10,
                RelativeSizeAxes = Axes.Both,
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
                Size             = new Vector2(0.9f, 0.8f),
                Children         = new Drawable[]
                {
                    new Box
                    {
                        Colour           = colours.GreySeafoamDark,
                        RelativeSizeAxes = Axes.Both,
                    },
                    fileSelector = new FileSelector(validFileExtensions: game.HandledExtensions.ToArray())
                    {
                        RelativeSizeAxes = Axes.Both,
                        Width            = 0.65f
                    },
                    new Container
                    {
                        RelativeSizeAxes = Axes.Both,
                        Width            = 0.35f,
                        Anchor           = Anchor.TopRight,
                        Origin           = Anchor.TopRight,
                        Children         = new Drawable[]
                        {
                            new Box
                            {
                                Colour           = colours.GreySeafoamDarker,
                                RelativeSizeAxes = Axes.Both
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Bottom = button_height + button_vertical_margin * 2
                                },
                                Child = new OsuScrollContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Anchor           = Anchor.TopCentre,
                                    Origin           = Anchor.TopCentre,
                                    Child            = currentFileText = new TextFlowContainer(t => t.Font = OsuFont.Default.With(size: 30))
                                    {
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                        Anchor           = Anchor.Centre,
                                        Origin           = Anchor.Centre,
                                        TextAnchor       = Anchor.Centre
                                    },
                                    ScrollContent =
                                    {
                                        Anchor = Anchor.Centre,
                                        Origin = Anchor.Centre,
                                    }
                                },
                            },
                            importButton = new TriangleButton
                            {
                                Text             = "匯入",
                                Anchor           = Anchor.BottomCentre,
                                Origin           = Anchor.BottomCentre,
                                RelativeSizeAxes = Axes.X,
                                Height           = button_height,
                                Width            = 0.9f,
                                Margin           = new MarginPadding {
                                    Vertical = button_vertical_margin
                                },
                                Action = () => startImport(fileSelector.CurrentFile.Value?.FullName)
                            }
                        }
                    }
                }
            };

            fileSelector.CurrentFile.BindValueChanged(fileChanged, true);
            fileSelector.CurrentPath.BindValueChanged(directoryChanged);
        }
 public GlobalKeyBindingInputManager(Storage storage)
     : base(SimultaneousBindingMode.All)
 {
     this.storage = storage;
 }
Beispiel #48
0
    public static object[] ConfirmUpload(object[] args)
    {
        var        nodeID = (string)args[0];
        var        fileID = (string)args[1];
        BigInteger size   = (long)args[2];

        var node = Storage.Get(Storage.CurrentContext, nodeID);

        if (node == null)
        {
            Fatal("absent value");
        }

        Node n = NDeserialize(node);

        if (n.free < size)
        {
            Fatal("insufficient space");
        }

        n.free = n.free - size;

        var        fp       = nodeF + nodeID;
        var        countRaw = Storage.Get(Storage.CurrentContext, fp);
        BigInteger count    = countRaw.AsBigInteger();

        count = count + 1;
        Storage.Put(Storage.CurrentContext, fp, count.AsByteArray());
        Storage.Put(Storage.CurrentContext, fp + count, fileID);

        Storage.Put(Storage.CurrentContext, nodeID, NSerialize(n));

        File file;
        var  fileRaw = Storage.Get(Storage.CurrentContext, fileS + fileID);

        if (fileRaw == null)
        {
            file = new File();
        }
        else
        {
            file = FDeserialize(fileRaw);
        }

        byte[] id = (byte[])args[0];
        if (file.node1 == null || file.node1.Length == 0)
        {
            file.node1 = id;
        }
        else if (file.node2 == null || file.node2.Length == 0)
        {
            file.node2 = id;
        }
        else if (file.node3 == null || file.node3.Length == 0)
        {
            file.node3 = id;
        }
        else if (file.node4 == null || file.node4.Length == 0)
        {
            file.node4 = id;
        }

        Storage.Put(Storage.CurrentContext, fileS + fileID, FSerialize(file));

        return(new object[] { n.free });
    }
Beispiel #49
0
 public OsuConfigManager(Storage storage)
     : base(storage)
 {
 }
        private void DoAuthorization()
        {
            if (!ValidateCredentials())
            {
                return;
            }

            IsInLoginIn = true;
            Authorization.Authorization.DoAuthorizationAsync(
                Login,
                Password,
                AccessToken,
                UseAccessToken
                ).ContinueWith(task =>
            {
                var responseResult = task.Result;
                switch (responseResult)
                {
                case AuthorizationResponseTypes.Success:
                    AuthorizationRequestDelay.DelayMsModifier = 0;
                    Storage.AddSecuredCreds(Login, UseAccessToken
                            ? $"{AccessToken}&token=true"
                            : Password
                                            );
                    IsWrongPassword = false;
                    IsInLoginIn     = false;
                    break;

                case AuthorizationResponseTypes.NeedVerifyCodeByApp:
                    VerificationRequestType   = VerificationRequestTypes.Application;
                    IsInLoginIn               = false;
                    SavedAccountsExists       = false;
                    SelectedSavedAccountIndex = -1;
                    IsInValidation            = true;
                    IsWrongPassword           = false;
                    break;

                case AuthorizationResponseTypes.NeedVerifyCodeByPhone:
                    VerificationRequestType   = VerificationRequestTypes.Phone;
                    IsInLoginIn               = false;
                    SavedAccountsExists       = false;
                    SelectedSavedAccountIndex = -1;
                    IsInValidation            = true;
                    IsWrongPassword           = false;
                    break;

                case AuthorizationResponseTypes.WrongCredentials:
                    AuthorizationRequestDelay.RecalculateRequests();
                    IsInLoginIn = false;
                    AuthorizationNotify.NotifyWrongPassword(Login, Password);
                    Password        = string.Empty;
                    IsWrongPassword = true;
                    ThrowAuthFailedInAppNotify(false);
                    break;

                case AuthorizationResponseTypes.WrongAccessToken:
                    AuthorizationRequestDelay.RecalculateRequests();
                    IsInLoginIn = false;
                    AuthorizationNotify.NotifyWrongPassword(
                        login: Login,
                        token: AccessToken,
                        isUseToken: UseAccessToken
                        );
                    AccessToken     = string.Empty;
                    IsWrongPassword = true;
                    ThrowAuthFailedInAppNotify(false, true);
                    break;

                case AuthorizationResponseTypes.UnexpectedResponse:
                    AuthorizationRequestDelay.RecalculateRequests();
                    ThrowAuthFailedInAppNotify(
                        false,
                        false,
                        true
                        );
                    IsWrongPassword = true;
                    break;
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
 public bool IsOutArgument(Storage stg)
 {
     return(returnRegisters.Contains(stg));
 }
Beispiel #52
0
 public bool IsStackRegister(Storage stg)
 {
     return(stg == program.Architecture.StackRegister);
 }
Beispiel #53
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.AddOrGet <LoopingSounds>();
            go.AddOrGet <DropAllWorkable>();
            Prioritizable.AddRef(go);

            List <Storage.StoredItemModifier> mod = new List <Storage.StoredItemModifier>
            {
                Storage.StoredItemModifier.Hide, Storage.StoredItemModifier.Insulate, Storage.StoredItemModifier.Preserve, Storage.StoredItemModifier.Seal
            };

            Storage storage = BuildingTemplates.CreateDefaultStorage(go);

            storage.SetDefaultStoredItemModifiers(mod);
            storage.showInUI   = true;
            storage.capacityKg = 20000f;
            storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.elementToConsume  = SimHashes.Methane;
            elementConsumer.consumptionRate   = 1000f;
            elementConsumer.consumptionRadius = 10;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
            elementConsumer.isRequired        = false;
            elementConsumer.storeOnConsume    = true;
            elementConsumer.showDescriptor    = false;

            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass   = 100f;
            elementDropper.emitTag    = new Tag("SolidMethane");
            elementDropper.emitOffset = new Vector3(0f, 0f, 0f);

            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[]
            {
                new ElementConverter.ConsumedElement(new Tag("Ice"), 1f),
                new ElementConverter.ConsumedElement(new Tag("Methane"), 1.0f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(1.0f, SimHashes.SolidMethane, 50.15f, storeOutput: true, 0f, 0f, apply_input_temperature: false, diseaseWeight: 0f, addedDiseaseIdx: byte.MinValue)
            };

            ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag = new Tag("Ice");
            manualDeliveryKG.capacity         = 1000f;
            manualDeliveryKG.refillMass       = 10f;
            manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.FetchCritical.IdHash;

            NaturalGasScrubber NaturalGasScrubber = go.AddOrGet <NaturalGasScrubber>();

            NaturalGasScrubber.filterTag = new Tag("Ice");

            go.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
        }
Beispiel #54
0
 protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorage(host, defaultStorage);
Beispiel #55
0
        public void Init()
        {
            this.InitializeComponent();

            m_root = new Root(Storage.Load(), FindResource("FolderColors") as IEnumerable <Color>);
        }
 public bool IsArgument(Storage stg)
 {
     return(argRegisters.Contains(stg));
 }
Beispiel #57
0
 public OsuConfigManager(Storage storage)
     : base(storage)
 {
     Migrate();
 }
Beispiel #58
0
 public void Delete(Storage value)
 {
     CurrentSession.SaveOrUpdate(value);
 }
Beispiel #59
0
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            PersonalStory story;

            context.PrivateConversationData.TryGetValue <PersonalStory>(key, out story);
            story = story ?? new PersonalStory();

            var message = await argument;

            var msg = new Message()
            {
                PartitionKey = message.Recipient.Id,
                RowKey       = $"{message.From.Id}_{DateTime.UtcNow}",
                Timestamp    = DateTime.UtcNow,
                Content      = message.Text,
                Task         = (int)story.Task
            };

            var storage = new Storage();
            await storage.Save(msg);

            switch (story.Task)
            {
            case PersonalStoryTask.Theme:
                story.Theme = message.Text;
                story.Task  = PersonalStoryTask.Description;
                break;

            case PersonalStoryTask.Description:
                story.Content = message.Text;
                story.Task    = PersonalStoryTask.Images;
                break;
            }

            if (null != message.Attachments && 0 < message.Attachments.Count)
            {
                story.Images = new string[message.Attachments.Count];
                for (var i = 0; i < message.Attachments.Count; i++)
                {
                    story.Images[i] = message.Attachments[i].ContentUrl;
                }
            }

            if (!string.IsNullOrWhiteSpace(story.Theme) && !string.IsNullOrWhiteSpace(story.Content) && null != story.Images && 0 < story.Images.Length)
            {
                var a      = await argument;
                var entity = new PersonalStoryEntity()
                {
                    PartitionKey = a.Recipient.Id,
                    RowKey       = a.From.Id,
                    Content      = story.Content,
                    Theme        = story.Theme,
                    Images       = string.Join(", ", story.Images),
                    Timestamp    = DateTime.UtcNow,
                };
                await storage.Save(entity);

                story.Task = PersonalStoryTask.Done;
            }

            var replyToConversation = await CreateResponse(context, story);

            await context.PostAsync(replyToConversation);

            context.PrivateConversationData.SetValue <PersonalStory>(key, story);

            context.Wait(MessageReceivedAsync);
        }
Beispiel #60
0
 public override void Do()
 {
     _variable = GetFromStorage(_variable.Name);
     Storage.Remove(_variable.Name);
 }