Example #1
0
        /// <summary>
        /// 获取指定终端编号在指定时间段内的历史轨迹
        /// </summary>
        /// <param name="aTerminalId">终端编号</param>
        /// <param name="aStart">开始时间</param>
        /// <param name="aEnd">结束时间</param>
        /// <returns></returns>
        public static JsonHistoryPosition GetHistory(string aTerminalId, DateTime aStart, DateTime aEnd)
        {
            string jsonStr = GetApiReply(GetHistoricalPosition(aTerminalId, aStart, aEnd));

            if (string.IsNullOrEmpty(jsonStr))
            {
                return(null);
            }

            JsonHistoryPosition historyLocation = ModelUtils.GetJsonObject <JsonHistoryPosition>(jsonStr);

            if (historyLocation != null)
            {
                return(historyLocation);
            }
            JsonBase errInfo = ModelUtils.GetJsonObject <JsonBase>(jsonStr);

            if (errInfo == null)
            {
                return(null);
            }

            // 重新组合返回错误值
            return(new JsonHistoryPosition
            {
                Status = errInfo.Status,
                Message = errInfo.Message
            });
        }
        public void Initialize()
        {
            if (_qkvSameDim)
            {
                ModelUtils.InitXavierUniform(QProjection.weight, 1.0 / Math.Sqrt(2.0));
                ModelUtils.InitXavierUniform(KProjection.weight, 1.0 / Math.Sqrt(2.0));
                ModelUtils.InitXavierUniform(VProjection.weight, 1.0 / Math.Sqrt(2.0));
            }
            else
            {
                ModelUtils.InitXavierUniform(QProjection.weight);
                ModelUtils.InitXavierUniform(KProjection.weight);
                ModelUtils.InitXavierUniform(VProjection.weight);
            }

            ModelUtils.InitXavierUniform(OutProjLinear.weight);

            if (_addBiasProj)
            {
                ModelUtils.InitConstant(QProjection.bias, 0);
                ModelUtils.InitConstant(KProjection.bias, 0);
                ModelUtils.InitConstant(VProjection.bias, 0);
                ModelUtils.InitConstant(OutProjLinear.bias, 0);
            }

            if (_addBiasKv)
            {
                ModelUtils.InitXavierUniform(KBias);
                ModelUtils.InitXavierUniform(VBias);
            }
        }
Example #3
0
        Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively)
        {
            NSpecAssemblyTest assemblyTest;

            if (!assemblyTests.TryGetValue(assembly, out assemblyTest))
            {
                assemblyTest      = new NSpecAssemblyTest(assembly.Name, assembly, frameworkVersion);
                assemblyTest.Kind = TestKinds.Assembly;

                ModelUtils.PopulateMetadataFromAssembly(assembly, assemblyTest.Metadata);

                string frameworkName = String.Format("NSpec v{0}", frameworkVersion);
                assemblyTest.Metadata.SetValue(MetadataKeys.Framework, frameworkName);
                assemblyTest.Metadata.SetValue(MetadataKeys.File, assembly.Path);
                assemblyTest.Kind = TestKinds.Assembly;

                parentTest.AddChild(assemblyTest);
                assemblyTests.Add(assembly, assemblyTest);
            }

            if (populateRecursively)
            {
                var reflector = new NSpec.Domain.Reflector(assembly.Path);
                var finder    = new SpecFinder(reflector);
                var builder   = new ContextBuilder(finder, new DefaultConventions());

                ContextCollection contexts = builder.Contexts();
                contexts.Build();
                contexts.Do(c => assemblyTest.AddChild(this.CreateGallioTestFrom(c)));
            }

            return(assemblyTest);
        }
Example #4
0
        private void InvalidateTracks()
        {
            if (Tracks == null)
            {
                return;
            }

            if (Width > 0)
            {
                _renderer.Settings.Width = (int)(Width / _displayDensity);

                _initialRenderCompleted = false;
                _isRendering            = true;
                var tracks = Tracks.ToArray();
                if (tracks.Length > 0)
                {
                    ModelUtils.ApplyPitchOffsets(_renderer.Settings, tracks[0].Score);
                    Task.Factory.StartNew(() =>
                    {
                        _renderer.Render(tracks[0].Score, tracks.Select(t => t.Index).ToArray());
                    });
                }
            }
            else
            {
                _initialRenderCompleted = false;
                _redrawPending          = true;
            }
        }
        public void ShowModel(Model3D model3D, bool updateCamera)
        {
            try
            {
                ContentVisual.SetCurrentValue(ModelVisual3D.ContentProperty, model3D);

                // NOTE:
                // We could show both solid model and wireframe in WireframeVisual3D (ContentWireframeVisual) with using WireframeWithOriginalSolidModel for WireframeType.
                // But in this sample we show solid frame is separate ModelVisual3D and therefore we show only wireframe in WireframeVisual3D.
                ContentWireframeVisual.BeginInit();
                ContentWireframeVisual.SetCurrentValue(Ab3d.Visuals.WireframeVisual3D.ShowPolygonLinesProperty, ReadPolygonIndicesCheckBox.IsChecked ?? false);
                ContentWireframeVisual.SetCurrentValue(Ab3d.Visuals.WireframeVisual3D.OriginalModelProperty, model3D);
                ContentWireframeVisual.EndInit();

                if (AddLineDepthBiasCheckBox.IsChecked ?? false)
                {
                    // To specify line depth bias to the Ab3d.PowerToys line Visual3D objects,
                    // we use SetDXAttribute extension method and use LineDepthBias as DXAttributeType
                    // NOTE: This can be used only before the Visual3D is created by DXEngine.
                    // If you want to change the line bias after the object has been rendered, use the SetDepthBias method (see OnAddLineDepthBiasCheckBoxCheckedChanged)
                    //
                    // See DXEngineVisuals/LineDepthBiasSample for more info.
                    ContentWireframeVisual.SetDXAttribute(DXAttributeType.LineDepthBias, model3D.Bounds.GetDiagonalLength() * 0.001);
                }

                // Calculate the center of the model and its size
                // This will be used to position the camera

                if (updateCamera)
                {
                    var bounds = model3D.Bounds;

                    var modelCenter = new Point3D(bounds.X + bounds.SizeX / 2,
                                                  bounds.Y + bounds.SizeY / 2,
                                                  bounds.Z + bounds.SizeZ / 2);

                    var modelSize = Math.Sqrt(bounds.SizeX * bounds.SizeX +
                                              bounds.SizeY * bounds.SizeY +
                                              bounds.SizeZ * bounds.SizeZ);

                    Camera1.TargetPosition = modelCenter;
                    Camera1.SetCurrentValue(Ab3d.Cameras.BaseTargetPositionCamera.DistanceProperty, modelSize * 2);
                }

                // If the read model already define some lights, then do not show the Camera's light
                if (ModelUtils.HasAnyLight(model3D))
                {
                    Camera1.SetCurrentValue(Ab3d.Cameras.BaseCamera.ShowCameraLightProperty, ShowCameraLightType.Never);
                }
                else
                {
                    Camera1.SetCurrentValue(Ab3d.Cameras.BaseCamera.ShowCameraLightProperty, ShowCameraLightType.Always);
                }

                ShowInfoButton.SetCurrentValue(IsEnabledProperty, true);
            }
            catch
            {
            }
        }
Example #6
0
        public override void ElementDeleted(ElementDeletedEventArgs e)
        {
            base.ElementDeleted(e);

            var inheritance = e.ModelElement as Inheritance;

            if (inheritance != null)
            {
                if (inheritance.TargetEntityType != null)
                {
                    // We need to invalidate the target entitytypeshape element; so base type name will be updated correctly.
                    foreach (var pe in PresentationViewsSubject.GetPresentation(inheritance.TargetEntityType))
                    {
                        var entityShape = pe as EntityTypeShape;
                        if (entityShape != null)
                        {
                            entityShape.Invalidate();
                        }
                    }
                }

                var tx = ModelUtils.GetCurrentTx(inheritance.Store);
                Debug.Assert(tx != null);
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new InheritanceDelete(inheritance));
                }
            }
        }
Example #7
0
        /// <summary>
        /// 将枚举集合加载到ComboBox列表中
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="aCtrl"></param>
        /// <param name="aSelect"></param>
        /// <param name="aItems"></param>
        public static void LoadEnumLst <T>(ComboBox aCtrl, T aSelect, params T[] aItems) where T : IComparable
        {
            if (aItems == null || aItems.Length <= 0)
            {
                LoadEnumLst <T>(aCtrl, aSelect);
                return;
            }

            aCtrl.Items.Clear();
            List <ValueString <T> > enumLst = ModelUtils.ToList <T>();

            if (enumLst == null || enumLst.Count <= 0)
            {
                return;
            }

            foreach (ValueString <T> tmpItem in enumLst)
            {
                if (aItems.Contains(tmpItem.Value))
                {
                    aCtrl.Items.Add(tmpItem);
                    if (aSelect.CompareTo(tmpItem.Value) == 0)
                    {
                        aCtrl.SelectedItem = tmpItem;
                    }
                }
            }

            if (aCtrl.Items.Count > 0 && aCtrl.SelectedIndex < 0)
            {
                aCtrl.SelectedIndex = 0;
            }
            aCtrl.Refresh();
        }
Example #8
0
        /// <summary>
        ///     Do the following when a new EntityType shape is created:
        ///     - Add the new EntityType to the model
        /// </summary>
        /// <param name="e"></param>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            base.ElementAdded(e);

            var addedEntity = e.ModelElement as EntityType;

            Debug.Assert(addedEntity != null);
            Debug.Assert(addedEntity.EntityDesignerViewModel != null);

            if ((addedEntity != null) &&
                (addedEntity.EntityDesignerViewModel != null))
            {
                var viewModel = addedEntity.EntityDesignerViewModel;
                Debug.Assert(viewModel != null);

                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null, "Make sure we have a Current Active Tx");
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    // Remove the added DSL EntityType.
                    // When Escher model is updated, there will be a code that will create the EntityType back
                    viewModel.EntityTypes.Remove(addedEntity);
                    addedEntity.Delete();

                    // create the model change and add it to the current transaction changelist
                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new EntityTypeAdd());
                }
            }
        }
Example #9
0
 protected void Initialize()
 {
     if (Options.FreezeEncoder)
     {
         ModelUtils.FreezeModuleParams(Encoder);
     }
 }
Example #10
0
        //
        // GET: /Admin/Widget/

        public ActionResult Index(WidgetIndexModel model)
        {
            int totale = 0;

            model.Widget = WidgetRepository.Instance.RecuperaWidget(model.Testo, model.TipoWidget, model.IndiceInizio, model.IndiceInizio + model.DimensionePagina, out totale);

            model.TipoWidgetSelectList = ModelUtils.CreaTipoWidgetSelectList(false);
            model.TotaleRisultati      = totale;

            if (model.TipoWidget == TipoWidget.Notizie)
            {
                model.EditaActionName = "Edita";
            }
            else if (model.TipoWidget == TipoWidget.Embed)
            {
                model.EditaActionName = "EditaEmbed";
            }
            else if (model.TipoWidget == TipoWidget.InEvidenza)
            {
                model.EditaActionName = "EditaInEvidenza";
            }
            else if (model.TipoWidget == TipoWidget.Sezione)
            {
                model.EditaActionName = "EditaSezione";
            }

            return(View(model));
        }
Example #11
0
        public ActionResult Edita(int id)
        {
            ActionResult            result = null;
            WidgetNotiziaEditaModel model  = new WidgetNotiziaEditaModel();
            Widget widget = null;

            widget = WidgetRepository.Instance.RecuperaWidget(id);

            if (widget != null)
            {
                model.Widget = widget;

                model.ID        = id;
                model.EditaNome = widget.Nome_IT;
                model.EditaCategoriaNotiziaID = widget.Categoria.ID;
                model.EditaMax = widget.NumeroElementi.Value;

                model.CategorieSelectList = ModelUtils.CreaCategoriaNotiziaSelectList(true);
                result = View(model);
            }
            else
            {
                result = HttpNotFound();
            }

            return(View(model));
        }
Example #12
0
        public ActionResult EditaEmbed(int id)
        {
            ActionResult          result = null;
            WidgetEmbedEditaModel model  = new WidgetEmbedEditaModel();
            Widget widget = null;

            widget = WidgetRepository.Instance.RecuperaWidget(id);

            if (widget != null)
            {
                model.Widget = widget;

                model.ID                = id;
                model.EditaNome_IT      = widget.Nome_IT;
                model.EditaNome_EN      = widget.Nome_EN;
                model.EditaContenuto_IT = UrlUtility.VAHtmlReplacePseudoUrls(widget.Contenuto_IT);
                model.EditaContenuto_EN = UrlUtility.VAHtmlReplacePseudoUrls(widget.Contenuto_EN);
                model.MostraTitolo      = widget.MostraTitolo;
                model.BooleanSelectList = ModelUtils.CreaBooleanSelectList();


                result = View(model);
            }
            else
            {
                result = HttpNotFound();
            }

            return(View(model));
        }
Example #13
0
        public ActionResult Edita(int id)
        {
            ActionResult        result           = null;
            CaroselloEditaModel model            = new CaroselloEditaModel();
            OggettoCarosello    oggettoCarosello = null;

            oggettoCarosello = OggettoCaroselloRepository.Instance.RecuperaOggettoCarosello(id);

            if (oggettoCarosello != null)
            {
                model.OggettoCarosello = oggettoCarosello;

                model.ID = id;
                model.EditaContenutoID              = oggettoCarosello.ContenutoID;
                model.EditaImmagineID               = oggettoCarosello.ImmagineID;
                model.EditaData                     = oggettoCarosello.Data;
                model.EditaNome_IT                  = oggettoCarosello.Nome_IT;
                model.EditaNome_EN                  = oggettoCarosello.Nome_EN;
                model.EditaDescrizione_IT           = oggettoCarosello.Descrizione_IT;
                model.EditaDescrizione_EN           = oggettoCarosello.Descrizione_EN;
                model.EditaLinkProgettoCartografico = oggettoCarosello.LinkProgettoCartografico;
                model.EditaPubblicato               = oggettoCarosello.Pubblicato;
                model.ImmaginiSelectList            = ModelUtils.CreaImmaginiCaroselloSelectList(true);
                model.ImmagineMasterID              = ImmagineRepository.Instance.RecuperaImmagine((int)model.EditaImmagineID).ImmagineMasterID;
                model.EditaTipoContenutoID          = oggettoCarosello.TipoContenuto;
                result = View(model);
            }
            else
            {
                result = HttpNotFound();
            }

            return(View(model));
        }
Example #14
0
        /// <summary>
        /// 获取指定终端最新的位置信息
        /// </summary>
        /// <param name="aTerminalId">终端编号</param>
        /// <returns>null服务器无响应</returns>
        public static JsonLastPosition GetLastLocation(string aTerminalId)
        {
            string jsonStr = GetApiReply(GetLastPosition(aTerminalId));

            if (string.IsNullOrEmpty(jsonStr))
            {
                return(null);
            }
            JsonLastPosition lastLocation = ModelUtils.GetJsonObject <JsonLastPosition>(jsonStr);

            if (lastLocation != null)
            {
                lastLocation.UpdateTime = DateTime.Now;
                return(lastLocation);
            }
            JsonBase errInfo = ModelUtils.GetJsonObject <JsonBase>(jsonStr);

            if (errInfo == null)
            {
                return(null);
            }

            // 重新组合返回错误值
            return(new JsonLastPosition
            {
                Status = errInfo.Status,
                Message = errInfo.Message
            });
        }
Example #15
0
        protected override void OnDeleting()
        {
            base.OnDeleting();

            if (EntityType != null &&
                EntityType.EntityDesignerViewModel != null &&
                EntityType.EntityDesignerViewModel.Reloading == false)
            {
                var viewModel = EntityType.EntityDesignerViewModel;
                var tx        = ModelUtils.GetCurrentTx(Store);
                Debug.Assert(tx != null);
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    // deleting the property would select the Diagram, select parent Entity instead
                    var diagram = viewModel.GetDiagram();
                    if (diagram != null &&
                        diagram.ActiveDiagramView != null)
                    {
                        var shape = diagram.FindShape(EntityType);
                        if (shape != null)
                        {
                            diagram.ActiveDiagramView.Selection.Set(new DiagramItem(shape));
                        }
                    }

                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new PropertyDelete(this));
                }
            }
        }
Example #16
0
 public ProviderItem(WatchProviderItem providerItem)
 {
     DisplayPriority = providerItem.DisplayPriority;
     LogoPath        = ModelUtils.GetImageUri(providerItem.LogoPath);
     ProviderId      = providerItem.ProviderId;
     ProviderName    = providerItem.ProviderName;
 }
    /// <summary>
    /// Creates a new implementation version from a a string.
    /// </summary>
    /// <param name="value">The string containing the version information.</param>
    /// <exception cref="FormatException"><paramref name="value"/> is not a valid version string.</exception>
    public ImplementationVersion(string value)
    {
        if (string.IsNullOrEmpty(value))
        {
            throw new FormatException(Resources.MustStartWithDottedList);
        }

        if (ModelUtils.ContainsTemplateVariables(value))
        {
            _verbatimString = value;
            return;
        }

        var parts = value.Split('-');

        // Ensure the first part is a dotted list
        if (!VersionDottedList.IsValid(parts[0]))
        {
            throw new FormatException(Resources.MustStartWithDottedList);
        }
        FirstPart = new VersionDottedList(parts[0]);

        // Iterate through all additional parts
        var additionalParts = new VersionPart[parts.Length - 1];

        for (int i = 1; i < parts.Length; i++)
        {
            additionalParts[i - 1] = new VersionPart(parts[i]);
        }
        AdditionalParts = additionalParts;
    }
Example #18
0
    private List <GameObject> renderModelObject(Dictionary <String, ModelObject> models, GameObject parentGo)
    {
        var result = new List <GameObject>();

        foreach (var modelObject in models)
        {
            try
            {
                var go = createModelObject(modelObject.Key, modelObject.Value, parentGo);
                renderModelObject(modelObject.Value.Models, go);
                result.Add(go);

                if (modelObject.Value is StateObject)
                {
                    ModelUtils.UpdateLight(go, ((StateObject)modelObject.Value).State);
                }

                gameModelObjects.Add(modelObject.Key, go);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
        }
        return(result);
    }
Example #19
0
        private XmlDocument GetServiceMetadataXml(string url)
        {
            XmlDocument doc;

            try
            {
                TestData.SetupDevDatabase(this.context);

                var values = url.Split('/');
                var participantIdentifier = ModelUtils.Urldecode(values[1]);
                var documentIdentifier    = ModelUtils.Urldecode(values[3]);
                var services =
                    (from x in this.context.SmpServices.Include(x => x.PeppolParticipant).Include(x => x.PeppolProcess)
                     .Include(x => x.Endpoints).Include(x => x.PeppolDocument)
                     where x.PeppolParticipant.Identifier == participantIdentifier &&
                     x.PeppolDocument.Identifier == documentIdentifier
                     select x).ToList();
                if (services.Count == 0)
                {
                    return(null);
                }

                doc = this.CreateXml(services);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + " " + ex.StackTrace);
                throw;
            }
            return(doc);
        }
Example #20
0
        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    EventsLV.IsSubscribed = false;
                    EventsLV.ChangeArea(ExpandedNodeId.ToNodeId(ObjectIds.Plaforms, m_session.NamespaceUris), true);

                    TypeDeclaration type = new TypeDeclaration();
                    type.NodeId       = ExpandedNodeId.ToNodeId(ObjectTypeIds.WellTestReportType, m_session.NamespaceUris);
                    type.Declarations = ModelUtils.CollectInstanceDeclarationsForType(m_session, type.NodeId);

                    EventsLV.ChangeFilter(new FilterDeclaration(type, null), true);
                    m_connectedOnce = true;
                }

                EventsLV.IsSubscribed = Events_EnableSubscriptionMI.Checked;
                EventsLV.ChangeSession(m_session, true);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Example #21
0
        /// <summary>
        /// 将枚举集合加载到ComboBox列表中
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="aCtrl"></param>
        /// <param name="aDefault"></param>
        public static void LoadEnumLst <T>(ComboBox aCtrl, T aDefault) where T : IComparable
        {
            aCtrl.Items.Clear();
            List <ValueString <T> > enumLst = ModelUtils.ToList <T>();

            if (enumLst == null || enumLst.Count <= 0)
            {
                return;
            }

            foreach (ValueString <T> tmpItem in enumLst)
            {
                aCtrl.Items.Add(tmpItem);
                if (aDefault.CompareTo(tmpItem.Value) == 0)
                {
                    aCtrl.SelectedItem = tmpItem;
                }
            }

            if (aCtrl.Items.Count > 0 && aCtrl.SelectedIndex < 0)
            {
                aCtrl.SelectedIndex = 0;
            }
            aCtrl.Refresh();
        }
Example #22
0
        /// <summary>
        /// This method will send a cancellation mail to both players in a confirmed match
        /// </summary>
        /// <param name="offer"></param>
        private void SendMatchCancellation(Offer offer)
        {
            var             fbContext   = FacebookWebContext.Current;
            var             tennisUsers = ModelUtils.GetTennisUsers(this.DB);
            TennisUserModel tennisUser1 = tennisUsers.Where(u => u.FacebookId == offer.FacebookId).FirstOrDefault();
            TennisUserModel tennisUser2 = tennisUsers.Where(u => u.FacebookId == offer.AcceptedById).FirstOrDefault();

            string location = OfferModel.GetLocationLink(LocationModel.Create(offer));

            Dictionary <string, string> tokens = new Dictionary <string, string>();

            tokens.Add("FacebookId1", tennisUser1.FacebookId.ToString());
            tokens.Add("Rating1", IndexModel.FormatRating(tennisUser1.Rating));
            tokens.Add("Name1", tennisUser1.Name.ToString());
            tokens.Add("FacebookId2", tennisUser2.FacebookId.ToString());
            tokens.Add("Rating2", IndexModel.FormatRating(tennisUser2.Rating));
            tokens.Add("Name2", tennisUser2.Name.ToString());

            tokens.Add("Date", IndexModel.FormatLongDate(offer.MatchDateUtc, tennisUser1.TimeZoneOffset));
            tokens.Add("Location", location);
            tokens.Add("Comments", offer.Message);
            tokens.Add("OfferId", offer.OfferId.ToString());

            string subject  = string.Format("TennisLoop: Match Cancelled");
            string template = Server.MapPath("/content/matchcancelled.htm");

            SendMessage(new long[] { tennisUser1.FacebookId, tennisUser2.FacebookId }, subject, template, tokens);
        }
Example #23
0
 TypeDefOptions CopyTo(TypeDefOptions options)
 {
     options.Attributes  = Attributes;
     options.Namespace   = Namespace;
     options.Name        = Name;
     options.PackingSize = PackingSize.Value;
     options.ClassSize   = ClassSize.Value;
     options.BaseType    = BaseTypeSig.ToTypeDefOrRef();
     options.CustomAttributes.Clear();
     options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));
     options.DeclSecurities.Clear();
     options.DeclSecurities.AddRange(DeclSecuritiesVM.Collection.Select(a => a.CreateDeclSecurityOptions().Create(ownerModule)));
     options.GenericParameters.Clear();
     options.GenericParameters.AddRange(GenericParamsVM.Collection.Select(a => a.CreateGenericParamOptions().Create(ownerModule)));
     options.Interfaces.Clear();
     options.Interfaces.AddRange(InterfaceImplsVM.Collection.Select(a => a.CreateTypeDefOrRefAndCAOptions().CreateInterfaceImpl(ownerModule)));
     if (ModelUtils.GetHasSecurityBit(options.DeclSecurities, options.CustomAttributes))
     {
         options.Attributes |= TypeAttributes.HasSecurity;
     }
     else
     {
         options.Attributes &= ~TypeAttributes.HasSecurity;
     }
     return(options);
 }
Example #24
0
        /// <summary>
        /// This method is called when user edits the user profile containing NTRP/Preference & other tennis user data
        /// </summary>
        /// <param name="ntrp"></param>
        /// <param name="preference"></param>
        /// <returns></returns>
        public ActionResult PostTennisUserDetails(string ntrp, string preference, string courtData, string style, bool emailOffers)
        {
            var fbContext = FacebookWebContext.Current;

            TennisUser tennisUser = this.DB.TennisUser.Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();
            User       user       = this.DB.User.Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();

            Court court = ProcessCourtData(courtData);

            user.EmailOffers          = emailOffers;
            tennisUser.Rating         = Convert.ToDouble(ntrp);
            tennisUser.SinglesDoubles = preference;
            tennisUser.Court          = court;
            tennisUser.PlayStyle      = style;

            this.DB.SubmitChanges();

            // Given the user details has changed, update all modules that are potentially impacted besides the UserDetails module itself
            return(Json(
                       new
            {
                UserDetails = RenderPartialViewToString("UserDetails", ModelUtils.GetModel <ModuleModel>(fbContext.UserId, this.DB)),
                QuickMatch = RenderPartialViewToString("QuickMatch", ModelUtils.GetModel <ModuleModel>(fbContext.UserId, this.DB)),
                Players = RenderPartialViewToString("Players", ModelUtils.GetModel <PlayersModel>(FacebookWebContext.Current.UserId, this.DB)),
                PotentialOffers = RenderPartialViewToString("PotentialOffers", ModelUtils.GetModel <PotentialOffersModel>(FacebookWebContext.Current.UserId, this.DB))
            }
                       ));
        }
        public virtual void Process(Type @class, TPrinter printer)
        {
            // NOTE: CHANGE IT!!!
            AssemblySelector selector = AssemblySelector.Get(@class.Assembly);

            ClassInclude  defaultClassInclude = selector.GetClassInclude(@class, printer.Diagram);
            ClassSelector classSelector       = ClassSelector.Get(@class, defaultClassInclude);

            printer.BeginClass(ModelUtils.ToClassType(@class),
                               PlantUmlUtils.GetSimpleName(@class),
                               PlantUmlUtils.GetGenerics(@class),
                               PlantUmlUtils.GetStereotypes(@class)?.ToArray());

            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetConstructors(@class), printer);
            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetMethods(@class), printer);
            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetProperties(@class), printer);
            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetEvents(@class), printer);
            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetFields(@class), printer);

            printer.EndClass();

            //this.ProcessNestedIfChecked(classSelector, ModelUtils.GetNestedTypes(@class), printer);

            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetGeneralizations(@class), printer);
            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetAssociations(@class), printer);
            this.ProcessMembersIfChecked(classSelector, ModelUtils.GetDependencies(@class), printer);
        }
Example #26
0
        public ActionResult PlayerDetails(long id)
        {
            TennisUserModel model = ModelUtils.GetTennisUsers(this.DB).Where(u => u.FacebookId == id).FirstOrDefault();

            if (null != model)
            {
                ViewData["PlayerModel"] = model;

                if (!Request.IsAjaxRequest())
                {
                    return(View());
                }

                return(Json
                       (
                           new
                {
                    PlayerDetails = RenderPartialViewToString("PlayerDetails", ModelUtils.GetModel <ModuleModel>(FacebookWebContext.Current.UserId, this.DB))
                },
                           JsonRequestBehavior.AllowGet
                       ));
            }

            return(Json(""));
        }
Example #27
0
 MethodDefOptions CopyTo(MethodDefOptions options)
 {
     options.ImplAttributes = ImplAttributes;
     options.Attributes     = Attributes;
     options.Name           = Name;
     options.MethodSig      = MethodSig;
     options.ImplMap        = PinvokeImpl ? ImplMap : null;
     options.CustomAttributes.Clear();
     options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));
     options.DeclSecurities.Clear();
     options.DeclSecurities.AddRange(DeclSecuritiesVM.Collection.Select(a => a.CreateDeclSecurityOptions().Create(ownerModule)));
     options.ParamDefs.Clear();
     options.ParamDefs.AddRange(ParamDefsVM.Collection.Select(a => a.CreateParamDefOptions().Create(ownerModule)));
     options.GenericParameters.Clear();
     options.GenericParameters.AddRange(GenericParamsVM.Collection.Select(a => a.CreateGenericParamOptions().Create(ownerModule)));
     options.Overrides.Clear();
     options.Overrides.AddRange(MethodOverridesVM.Collection.Select(a => a.CreateMethodOverrideOptions().Create()));
     if (ModelUtils.GetHasSecurityBit(options.DeclSecurities, options.CustomAttributes))
     {
         options.Attributes |= MethodAttributes.HasSecurity;
     }
     else
     {
         options.Attributes &= ~MethodAttributes.HasSecurity;
     }
     return(options);
 }
Example #28
0
        public ActionResult AcceptPlayerGrid(int page, string offerId)
        {
            Guid offerGuid;

            if (Guid.TryParse(offerId, out offerGuid))
            {
                ViewData["Page"] = page;


                var app       = new FacebookWebClient();
                var fbContext = FacebookWebContext.Current;

                TennisUserModel existingUser = ModelUtils.GetTennisUsers(this.DB).Where(tu => tu.FacebookId == fbContext.UserId).FirstOrDefault();
                var             model        = new AcceptPlayersDataGridModel(offerGuid, existingUser, this.DB);
                model.IsPostBack = false;

                return(Json
                       (
                           new
                {
                    PlayerGrid = RenderPartialViewToString("PlayerGrid", model)
                }
                       ));
            }
            else
            {
                // BUGBUG: return error
            }
            return(Json(""));
        }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            var inheritanceConnector = e.ModelElement as InheritanceConnector;

            Debug.Assert(inheritanceConnector != null);

            if (inheritanceConnector != null)
            {
                // for some reason when deleting connector, DSL invokes ChangeRule, so just return if it's deleted
                if (inheritanceConnector.IsDeleted)
                {
                    return;
                }

                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null);
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    if (e.DomainProperty.Id == LinkShape.EdgePointsDomainPropertyId ||
                        e.DomainProperty.Id == LinkShape.ManuallyRoutedDomainPropertyId)
                    {
                        ViewModelChangeContext.GetNewOrExistingContext(tx)
                        .ViewModelChanges.Add(new InheritanceConnectorChange(inheritanceConnector, e.DomainProperty.Id));
                    }
                }
            }
        }
Example #30
0
        sealed protected override void CalculateJqFrom(AnomalyCurrent eScattered, AnomalyCurrent jScattered, AnomalyCurrent jQ)
        {
            var anom = Model.Anomaly;



            for (int k = 0; k < Model.Anomaly.Layers.Count; k++)
            {
                var corrLayer  = ModelUtils.FindCorrespondingBackgroundLayer(Model.Section1D, anom.Layers[k]);
                var zeta       = corrLayer.Zeta;
                int layerIndex = k;
                if (Engine == ForwardSolverEngine.X3dScattered)
                {
                    CalculateJqFromScatteredField(anom.Zeta, k, eScattered, jScattered, zeta, jQ, ac => GetLayerAccessorX(ac, layerIndex));
                    CalculateJqFromScatteredField(anom.Zeta, k, eScattered, jScattered, zeta, jQ, ac => GetLayerAccessorY(ac, layerIndex));
                    CalculateJqFromScatteredField(anom.Zeta, k, eScattered, jScattered, zeta, jQ, ac => GetLayerAccessorZ(ac, layerIndex));
                }
                else
                {
                    CalculateJqFromTotalField(anom.Zeta, k, eScattered, zeta, jQ, ac => GetLayerAccessorX(ac, layerIndex));
                    CalculateJqFromTotalField(anom.Zeta, k, eScattered, zeta, jQ, ac => GetLayerAccessorY(ac, layerIndex));
                    CalculateJqFromTotalField(anom.Zeta, k, eScattered, zeta, jQ, ac => GetLayerAccessorZ(ac, layerIndex));
                }
            }
        }